This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: [Q] mktemp
- From: Teenu <brain_damage at eth dot net>
- To: Mihnea Balta <dark_lkml at mymail dot ro>
- Cc: Teenu <brain_damage at eth dot net>, GCC HELP <gcc-help at gcc dot gnu dot org>
- Date: Thu, 27 Feb 2003 19:12:23 +0530 (IST)
- Subject: 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 ?
>