I’ve 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.