Home > Back-end >  For entry (C) excuse me how behind the last write the structure of the array to write the second arr
For entry (C) excuse me how behind the last write the structure of the array to write the second arr

Time:09-16

 
void the add () {
Struct place m [100];
System (" CLS ");
FpOut fpIn FILE * and * and * fpnum;
char c;
Total=0;
FpOut=fopen (" Place_date. Out ", "ab");//the temporary file
FpIn=fopen (" Place_date. Dat ", "rb");//storage file
Fpnum=fopen (" number. TXT ", "r");
If (fpOut!=NULL) {
Printf (" \ \ t t1 on behalf of province, municipality directly under the central government \ t2 representative cities as \ n \ n \ t \ \ t t3 on behalf of the county, the flag, the SAR \ n \ \ t t4 represent street, town, township ");
Printf (" \ n \ t \ t please input level of administrative division: ");
The fflush (stdin);
The scanf (" % HHD ", & amp; M + 1] [total grade);
Printf (" please enter the region name: t \ \ t ");
The fflush (stdin);
The scanf (" % s ", m + 1] [total adr);
Printf (" \ t \ t please enter the postal code: ");
The fflush (stdin);
6 the scanf (" % d ", & amp; M + 1] [total pcode);
System (" CLS ");
Fwrite (& amp; M + 1] [total, sizeof (struct place), 1, fpOut);
The fflush (stdin);
Total++;
} else {
Printf (" unable to open file \ n "); }
The fclose (fpOut);
The fclose (fpIn);
Remove (" Place_date. Dat ");/* delete the original data file */
Rename (" Place_date. Out ", "Place_date. Dat");/* to the temporary file renamed data file */
}
After how change can be achieved 1. Write and save the next execution in the back of the last write information then write
2. Information on how to output has been saved

CodePudding user response:

FpIn=fopen (" Place_date. Dat ", "rb");//storage file r should be read-only files, can you write, additional should be ab +

CodePudding user response:

reference 1st floor CHXCHXKKK response:
fpIn=fopen (" Place_date. Dat ", "rb");//storage file r should be read-only files, can you write, additional should be ab +

I am using fpOut=fopen (" Place_date. Out ", "ab") write fopen (" Place_date. Dat ", "rb") is I want to used to read the content and copy to Place_date. Out because the code at the end of the Place_date. Out has been removed so that each time the add () in Place_date. Write out behind the information
  • Related