My program is seg faulting?
Hey guys... I'm trying to right this program to read basic info from /proc files and display it on the screen. The problem is it seg faults and I don't know why :\
Quote:
|
char item[50];
fgets( item, 100, cfPtr ); Sorry but this doesn't work. You've only allocated space for 49 characters and then you're allowing up to 100 to be stuffed there. Guaranteed segfault territory. Either use properly-sized arrays or malloc() enough memory for the task. C doesn't have on-the-fly memory compression yet :-) You may also want to try the various strcmp/strstr functions instead of going char by char. |
Thanks, knew it would be something stupid :\
|
All times are GMT -5. The time now is 02:33 AM. |