I've got a text file that has 2 columns and 35 rows of numbers. I am trying to read in the text file and output the 2 columns and 35 rows. With my code I am only getting the last two pieces of data from the file and it's printing the same data 35 times. Any thoughts?
Code:
#include <stdio.h>
int main()
{
int i,j;
float x,y;
FILE *fp;
fp=fopen("Data.txt", "rb");
for(j=0; j<35; j++)
for(i=0; i<2; i++)
fscanf(fp,"%f, %f", &x, &y);
for(j=0; j<35; j++)
for(i=0; i<2; i++)
printf("%f %f\n", x, y);
fclose(fp);
return 0;
}