Home > Back-end >  (1) from the file read 20 students English, physical fitness, security learn three classes of result
(1) from the file read 20 students English, physical fitness, security learn three classes of result

Time:09-22

#include
Struct a
{
int num;
Char name [20].
Int yingyu.
Int tiyu;
Int zhian;

} a, [20].
Int main ()
{

int i,j;
The FILE * fp=fopen (" lab 5. TXT ", "r");
If (fp==NULL)
{
Printf (" file ");
return -1;
}
for(i=0; i<20; I++)
{fscanf (fp, "% d % s % d % d % d", & amp; A [I]. Num, & amp; A [I]. Name, & amp; A [I]. Yingyu, & amp; A [I]. Tiyu, & amp; A [I] zhian);


}
fclose(fp);
for(i=0; i<20; I++)
{


Printf (" % d % s % d % 2. 2 d %. A 2 d ", a [I] num, [I] a name, a [I] yingyu, a [I] tiyu, a [I] zhian);

printf("\n");
}
Return 0;
}
I want to know why read not to come out

CodePudding user response:

Have a try, and you the inside of the file data format correct?
The FILE * fp=fopen (" lab 5. TXT ", "rb +");
  • Related