Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

strcpy causing segfaults from source

Name: Anonymous 2010-08-12 14:42

A snippet in my code goes something like

puts(string1);
strcpy(string2, string1);
puts(string1);

but that 2nd call of puts results in a segfault. I thought strcpy only copies. wtf is going on? I couldn't recreate it though on its own so I think it must be this project.

If you guys have nothing to do, maybe you can have a look.
http://pastebin.ca/1915922
It's part of a larger project but this one here reads two lines of text from a given file and separates the tokens that are separated by commas and spaces.

Name: Anonymous 2010-08-12 15:52

man, I'm stumped. I remember though that it used to work. My old code made use of a loop but then I was having trouble and I realized that since there will always be 6 items per line, I might as well just call strtok 6 times manually.

It would actually make it all the way to parsing the 2nd line that was read but with last string of the 2nd line replacing 1st string of the 1st line for some reason.

I also had variables initializations left over from the loop and when I removed those (since they weren't being used) that's when shit stopped working.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List