Bernhard Rieder ([EMAIL PROTECTED]) wrote:

> test.c: -----------------------------------
> #include <stdlib.h>
> 
> char *template = "/tmp/tmpfileXXXXXX";
> 
> int main () {
>    return printf("%s\n", mktemp(template));
> }
> -------------------------------------------

As others have noted, you cannot pass a string constant to mktemp().

Use this instead:

  char template[] = "/tmp/tmpfileXXXXXX";

Using the brackets ("[]") here forces the allocation of an array big
enough to hold the initializer value ("/tmp/tmpfileXXXXXX" with trailing
NUL character).  With the "char *" you're only allocating a pointer and
telling it to point to a string constant (which is in read-only memory).

-- 
Greg Wooledge                    | Distributed.NET http://www.distributed.net/
[EMAIL PROTECTED]             | because a CPU is a terrible thing to waste.
http://www.kellnet.com/wooledge/ |

Reply via email to