Home > Back-end >  C language small white for help! Would you please tell me why this problem is c is wrong?
C language small white for help! Would you please tell me why this problem is c is wrong?

Time:01-16

In c program, in binary form to store the integer to function in the file is
A.f printf function b. read function C.f write function D.f putc function

CodePudding user response:

Fwrite ah, in the form of a binary "wb" to open the file

CodePudding user response:

B is read, A and D is the character form; So choose C, if C is wrong, that's a problem, that is the wrong answer ~


https://wenku.baidu.com/view/f4332ec509a1284ac850ad02de80d4d8d15a01b6.html

CodePudding user response:

[in binary form to store the integer to file] what is the binary form here?
If it is 5, for example, in 101 to A file, that's A, using the format of the fprintf print can realize
C can realize bytes stored, but the store content itself is the hexadecimal

CodePudding user response:

C fwrite () function

CodePudding user response:

Can't draw themselves sober
AC is ok
A need some skills

CodePudding user response:

Correct ACD will do
There's a trick to AD

CodePudding user response:

Fwrite can be; But I can't stop to the fputc can:
Int fputc ( int c, FILE * stream);

CodePudding user response:

I also said fprintf can also, who to bicker with me, I'd drop this few lines of code for him:
 # include & lt; Stdio. H> 
Int main () {
Int I=0 x12345678;
The FILE * f=fopen (" data. Bin ", "wb");
Fprintf (f "% % % % c c c c", (char) (i> 24), (char) (i> 16 & amp; 0 XFF), (char) (i> 8 & amp; 0 XFF), (char) (i& 0 XFF));
The fclose (f);
return 0;
}



CodePudding user response:

Don't put the
Fopen ("... ", "... "); Fscanf fprintf, the fgets, fgetc fputc, fclose//read the replaced \ r \ n \ n, write to replace the \ n \ r \ n. EOF is read \ x1a set; When the content of the read and write characters see
And
Fopen ("... ", "... "); Fseek, ftell, fread and fwrite, fscanf, fprintf, the fgets, fgetc, fputc, fclose//do not make the above replacement, encounter \ x1a continued to read; When the content of the read and write bytes see
Confused by the

CodePudding user response:

Thank you for your answer!!!!!!
  • Related