|
Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006
Fread and fwrite
This is not a function of whether the two documents in what way is open to the binary output flow? Why no difference in output following two procedures?
#include "Stdio.h>
#include "Stdlib.h>
LEAVES OF 13 SPECIES OF LAURACEAE byte output of the order of testing procedures, the outcome of the first byte of low output, high output after byte */
Void main ()
{
Unsigned int a=25185;/*a=98*256+97*/
FILE* fp;
Fp=fopen ( "at no charge, a. Txt," "wb+"); 4003rd that read "wt+" has the same result?
If (fp==0) {puts ( "error") ;exit (0) ;}
Fwrite (&a, sizeof (unsigned int), 1, fp);
Fwrite (&a, sizeof (unsigned int), 1, stdout);
//stdout Originally binary equipment, why not 25185? output is ab
Putchar ( '\n');
Fclose (fp);
}
Based on the above comparison is only fwrite only binary output flow, heroes instructions. |
The so-called text mode binary form, stored in the computer sense, all are essentially the same, 01. Regarding the distinction between them for the different treatment (and possibly others, I learned only this).
Fwrite is faithful to its export your data.
In your example, you fwrite is four bytes, four bytes each fwrite this faithfully wrote on the paper, the standard output Lane.
As you can see, is simply the terminal, notebook display ways. If so, you can look at them with M-ary 16. |
(25185)10=(6261)16
So when you write is to write a 61,62 (byte sequence), which is ab, if you read it in the form of two or 25185 229
The difference between binary and text should not only for firms bars. There seems to influence eof
Binary mode and text mode is the biggest difference in the data organization
Binary way you write integer 1314, with the benchmark used to write text is different from 1314, 1314 using two 229 written would only use two bytes (16 aircraft), text mode is 4 bytes (the assic code), the binary approach requires meticulous organization of the data location / format Text mode is not so strict and convenient editing
Please enlighten said the wrong places |
-->
Fwrite landlord procedures Lane four bytes, not two. |
Not? If the DOS is to use two bytes TC
Landlord of several storage systems and the concept or not 啊~~~ |
Oh, I understand, thank! Binary mode to see how notepad paper? |
-->
This function can be no notebook
You can use the 16-band ultraEdit way to inspect or vim thalamotomy
Write the contents of a binary system is how they see the definition, 0x6162, you need to explain which is a binary number, the book is ab approach |
These are problems left by history ah.
If at the beginning. DOS\WINDOWS description of the C language. Not so among bars. |
| |