Segmentation fault when calling fgets

后端 未结 2 527
轮回少年
轮回少年 2021-01-22 17:46

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

2条回答
  •  鱼传尺愫
    2021-01-22 18:22

    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.

提交回复
热议问题