This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [Q] mktemp
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
int main(){
char tmp[32];
strncpy(tmp, "tmpXXXXXX", 32);
mkstemp(tmp);
printf("%s\n", tmp);
return 0;
}
You're using a constant string, and you're not allowed to write to constant
strings.
On Thursday 27 February 2003 13:24, Teenu wrote:
> Hello List,
> I wanted to generate tmp files by mktemp() and mkstemp() in a C++
> program. The use of these 2 functions result in segmentation faults.
> How do i use these ?
> Heres how i'm using them
> ______________________
> mkstemp("tempXXXXXX");
> ______________________
>
> GCC--> 2.96
> OS--> RedHat 7.1
> Kernel--> 2.5.6
>
> TIA
>
> Tc
>
>
> ------------------------------------------------------------------------
> P.S. Stiai ca s-a lansat www.FreeSMS.ro ?