Subject: Re: mktemp()
To: None <Chris_Mattingly@ncsu.edu>
From: Adam Glass <glass@NetBSD.ORG>
List: amiga-dev
Date: 03/16/1995 17:53:12
> In attempting to compile a program that uses mktemp(), I had 0% success.
> It causes a bus error every time...
> 
> Ex. prog.:
> 
> #include <unistd.h>
> int main()
> {
>   char *temp;
> 
>   temp = "/tmp/temp.XXXXXX";
>   mktemp(temp);
>   return 0;
> }
> 
> Has this been fixed in a more current -current than I have?
> 
> Thanks,
> Chris
> -- 

As you've written this, mktemp must be able to write to the string
pointed to by temp.  GCC puts string constants in text space so they
aren't writeable and thus mktemp() goes boom.  Try this instead:

#include <unistd.h>
int main()
{
  char temp[] = "/tmp/temp.XXXXXX";
  mktemp(temp);
  return 0;
}