Page 1 of 1

Need help with fread!

PostPosted: Feb 7, 2004 @ 10:42pm
by kornalius

PostPosted: Feb 7, 2004 @ 11:55pm
by Dan East

PostPosted: Feb 8, 2004 @ 1:14am
by kornalius

PostPosted: Feb 8, 2004 @ 1:27am
by Dan East
What does s point to? The memory allocated by strdup. How much memory did strdup allocate? 1 byte. strcat, strcpy, etc, do not allocate memory, they just write to the buffer you provide. So strcat is writing past the end of your buffer. If you change the strdup call to s=malloc(1024) (and then set s[0]=0) then it will work.

Dan East

PostPosted: Feb 8, 2004 @ 1:39am
by Dan East

PostPosted: Feb 8, 2004 @ 1:45am
by mlepage

PostPosted: Feb 8, 2004 @ 1:52am
by Dan East

PostPosted: Feb 8, 2004 @ 2:08am
by Dan East

PostPosted: Feb 8, 2004 @ 4:20am
by kornalius

PostPosted: Feb 8, 2004 @ 6:57am
by mlepage