Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to read the data in txt file into the array of the program with C language?
How to read the data in txt file into the array of the program with C language?
# include & ltstdio.h & gt

# include & ltstdlib.h & gt

main( ) {

FILE * fin

int a[50][2];

int I;

fin = fopen("abc.txt "," r "); //Open the file and open it as read.

for(I = 0; I & lt50; i++)

fscanf(fin," %d %d ",& ampa[i][0],& ampa[I][ 1]); //Cyclic reading

fclose(fin); //Close the file

for(I = 0; I & lt50; i++) printf("%d %d\n ",a[i][0],a[I][ 1]); //output.

Returns 0;

}