Does e go past MAXLINES? And is getline your own creation, since it doesn't seem to be the GNU version? If so, does it properly null-terminate things?
Does e go past MAXLINES? And is getline your own creation, since it doesn't seem to be the GNU version? If so, does it properly null-terminate things?
Yeah that's my version of getline and it does terminate the string. e does go past MAXLINES though.
Program received signal SIGSEGV, Segmentation fault.
0x08048648 in main (argc=2, argv=0xbffff4f4) at exercise.5-13.c:56
56 strcpy(lines[e++], storeline);
(gdb) print e
$1 = 134556832
Oh great, so you found the problem!
A more useful way to fix it would be to make lines a char** and allocate the array of char*'s dynamically. Then when you run out of empty char*s in the array you can malloc an array twice as big and copy the old char*'s across. Basically simulating a C++ vector.
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"