I\'m trying to write a simple program to read data from files listed in a plain text list, but I keep running into a segmentation fault when I try to call fgets() in my processF
fopen will return NULL if the file doesn't exist. Add some error handling after the call to fopen, it's possible you just have a bad entry in your list.
What may be happening is that pgmFile is NULL, and fgets tries to access it, causing the seg fault.
Try checking return value of fopen
. What if it's NULL
? Because it is likely that your "file name" has trailing \n
.