Here is my code:
#include <stdio.h>
int main() {
FILE *file;
file = fopen("data.txt", "r");
int Array[10];
int i = 0;
fscanf(file, "%d", &i);
while (!feof(file)) {
fArray[j] = i;
j++;
fscanf(file, "%d", &i);
}
fclose(file);
return 0;
}
when I run this on windows, it works fine, but when I try to run it on a mac I get a segmentation fault : 11.
The data.txt file is in the same folder as my test.c file which code is shown above.
I tried to pinpoint where the segmentation fault occurs, and it is when I make the call to fscanf().