This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [Q] mktemp


Thanks Mihnea ! that saved me a lot of time.

Regards,
Tc

On Thu, 27 Feb 2003, Mihnea Balta wrote:

> #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 ?
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]