This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: strcpy(stc->val,var) = Segmention Fault
You have a couple of these in your code:
stc->val=(char *) malloc(strlen(var));
strcpy(stc->val,var);
This is wrong. You are not allocating space for the terminating null
character and you are always overwriting the end of your allocated memory
zones. This just happens to work by chance on your other compiler, but it is
definitely not a surprise that it can give a segmentation fault.
--
Marcel Cox
"Uílton O. Dutra" <uilton@schmitt.com.br> wrote in message
200307181640030460.0015EFFB@mail.schmitt.com.br">news:200307181640030460.0015EFFB@mail.schmitt.com.br...
Hi folks,
I create simple program to read configurations files.
With Bcc32-Win98 my prog works fine, but on Gcc-Linux I got "Segmention
Fault" in "strcpy(stc->val,var)".
What's wrong?
Thanks,
UOD