Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How C Language Reads txt Content into Array
How C Language Reads txt Content into Array
# include & ltstdio.h & gt

# include & ltstdlib.h & gt

# Definition number 10000

int main()

{

FILE * fp

If ((fp = fopen ("d: \ \123.txt", "r ")= = null)// Judge whether the file was opened successfully?

{//Read the text file named 123 under drive D?

Printf ("File cannot be opened \ n");

Exit (0);

}

other

Printf ("File opened successfully \ n");

Double a [n];

for(int I = 0; I<5; I++)// Read five floating-point data.

fscanf(fp," %lf ",& ampa[I]); //The //fscanf function reads the data in the text in a fixed format; ?

for(int I = 0; I<5; i++)

printf("%.6lf,\n ",a[I]);

fclose(FP);

}?