Hi ppl. Beginner here..
I have a set of data
1 2 3 4 5 6 7 8 9
9 8 7 6 5 4 3 2 1
1 2 3 4 5 6 7 8 9
how do i use a fscanf statement to read the third number in the second row(which is 7 as highlighted)? R is the variable I use to store the read value. And if I want to replace it with some other number, for example, get input from the user and replace the number 7 with 5, how do I do it? Below is my code. Thanks!
Code:#include <stdio.h> #include <math.h> #include <stdlib.h> int main() { FILE* fx= fopen("cool.txt","r"); int i,j,R; for(i=1;i<3;i++) { for(j=1;j<4;j++) fscanf(fx,"%d ",&R); } fclose(fx); printf("R is %d ", R); return 0; }