I've been having issues with fscanf. In my code, I specify the name of the text file I am trying to load, but Xcode give me the EXC_BAD_ACCESS error whenever I try to use fscanf. The file I am trying to load is in the same directory as the code. What am I doing wrong?
int main(int argc, char *argv[]) {
int grid[9][9], i, j;
char inputfilename[40];
FILE *fp;
printf("Enter filename: ");
scanf("%s",&inputfilename[0]);
fp = fopen(inputfilename, "r");
for (i = 0; i < 9; i++) {
for (j = 0; j < 9; j++) {
fscanf(fp, "%d", &grid[i][j]);
}
}
return 1;
}