int main (int argc, const char * argv[]) {
Insert code here ...
FILE * fp = fopen ("Test.txt", "w");
fprintf (FP, "%d%d", 3, 5);
int x = 4;
Fwrite (&x, sizeof (int), 1, FP);
int x = ' 1 ';
Fwrite (&x, sizeof (int), 1, FP);
Fclose (FP);
fp = fopen ("Test.txt", "R");
int des = 0;
int des2 = 0;
FSCANF (FP, "%d%d", &des, &des2);
printf ("Des:%d%d\n", DES, des2);
Fread (&des, sizeof (int), 1, FP);
printf ("Des:%d\n", des);
return 0;
}
FSCANF according to%d read, will skip the previous n white space characters (\ t, \ n, "), encountered non-numeric character termination, so later if it is fwrite, in the last number of fprintf with a space class to distinguish, let fscanf read the number terminated.
fprintf and fwrite can be mixed, one is formatted output, one is ASCII output by byte
C language fprintf, Fwrite, fscanf, fread mixed problems