* [Q] mktemp
@ 2003-02-27 12:33 Teenu
2003-02-27 12:43 ` Mihnea Balta
0 siblings, 1 reply; 3+ messages in thread
From: Teenu @ 2003-02-27 12:33 UTC (permalink / raw)
To: GCC HELP
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Q] mktemp
2003-02-27 12:33 [Q] mktemp Teenu
@ 2003-02-27 12:43 ` Mihnea Balta
2003-02-27 13:51 ` Teenu
0 siblings, 1 reply; 3+ messages in thread
From: Mihnea Balta @ 2003-02-27 12:43 UTC (permalink / raw)
To: Teenu, GCC HELP
#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 ?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Q] mktemp
2003-02-27 12:43 ` Mihnea Balta
@ 2003-02-27 13:51 ` Teenu
0 siblings, 0 replies; 3+ messages in thread
From: Teenu @ 2003-02-27 13:51 UTC (permalink / raw)
To: Mihnea Balta; +Cc: Teenu, GCC HELP
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 ?
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-02-27 13:51 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27 12:33 [Q] mktemp Teenu
2003-02-27 12:43 ` Mihnea Balta
2003-02-27 13:51 ` Teenu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).