Writing to 2d array with fscan

558fe5180e0e8fc922d31c23ef84d240

Im trying to scan in a txt file with a string of numbers.

t.txt
123
223
323

<#include stdlib.c>
<#include stdio.c>
<#include string.h>


int main{
char grid[3][3];
int i = 0;

File *f = fopen(t.txt, r)

while (i != 3){
for (int j = 0; j < 3; j++){
fscanf(f, %1c, &grid[i][j]);
}
i++;
}


}

But it prints a segment fault.

Populating 2d array with scan

558fe5180e0e8fc922d31c23ef84d240

Im trying to scan in a txt file with a string of numbers.

t.txt
123
223
323

File *f = fopen(t.txt, r)

while (i != 3){
for (int j = 0; j < 3; j++){
fscanf(f, %1c, &grid[i][j]);
}
i++;
}

But it prints a segment fault.

Fscanf seg fault

558fe5180e0e8fc922d31c23ef84d240

Ive been trying to use the fscanf function to read a txt file containing a single number into a ptr:

(file.txt)

1

File *fPtr=fopen(file.txt, r)
int r;

fscanf(fPtr, %d, &r);

I keep getting a segmentation fault, after running it though the program compiles. It happens pretty much any other way I try to call Fscanf too.