I'm having trouble figuring out why my code is having a seg fault while reading code from a file in c. I've attached the code and valgrind output below. Thanks for any help!
FILE *fp;
fp = fopen("filename", "r");
char line[100];
while (fgets(line, 100, fp) != NULL) {
==4545== Invalid read of size 4
==4545== at 0x4E9E34B: fgets (iofgets.c:50)
==4545== by 0x401289: main (game.c:180)
==4545== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==4545==
==4545==
==4545== Process terminating with default action of signal 11 (SIGSEGV)
==4545== Access not within mapped region at address 0x0
==4545== at 0x4E9E34B: fgets (iofgets.c:50)
==4545== by 0x401289: main (game.c:180)