{
Int num.
char name[15];
Int score [M];
Float avg.
};
This is to define the structure
Below is the file
Void the file ()
{
int i,j,n;
FILE *fp;
Fp=fopen (" D: \ \ cj TXT ", "w");
If (fp==NULL)
{
Printf (" can't open the file! \n");
The exit (1);
}
for (i=0; i
fclose(fp);
Fp=fopen (" D: \ \ cj TXT ", "rb");
If (fp==NULL)
{
Printf (" can't open the file! \n");
The exit (1);
}
/* printf (" please enter the serial number of the students: ");
The scanf (" % d ", & amp; N);
Printf (" the student id you entered is: % d ", n);
Printf (" find student information is as follows: \ n ");
Fseek (fp, sizeof (n - 1) * (s), 0).
Fread (& amp; S, sizeof (s), 1, fp);
Printf (" % d % s % d % d % d % f ", s.n um, s.n ame, s.s core [0], s.s core [1], s.s core [2]). */
}
Compiled TXT file is messy code, and then by the way, can you help me take a look at/* */errors, thank you
CodePudding user response:
This is not gibberish, you is written according to the way of binary file, if according to the way of the text file to read and write files, you can refer tohttps://blog.csdn.net/zhanghaiyang9999/article/details/107032563
CodePudding user response:
If you don't want to "gibberish", it is suggested that using fscanf/fprintf, speaking, reading and writing files,Commented out part s undefined, n if input is zero, that this is a problem,
CodePudding user response: