Home > Back-end >  Int size problems in data in TXT
Int size problems in data in TXT

Time:10-24

Int 32-bit system is 4 bytes of data, but it is not a 4 bytes in TXT file (example: int I=4, put in TXT, its size is 1 byte, int I=21, in TXT, its size is 2 bytes), and this is to ask what?

CodePudding user response:

You can see the characters, is encoded, really put a 1 in to you don't understand

CodePudding user response:

Int 32 maximum 10, you wrote in TXT is 10 bytes oh
Said differently, memory is to use a fixed size of memory to an int, is not a text file, how much is how much of a
And memory corresponding files are binary file, binary file inside an int is 4 bytes

CodePudding user response:

What you see in TXT is characters, not bytes, you will write files in binary way is bytes, so the TXT see 4 is a character, accounting for 1 byte (c 1 char is 1 byte), 21 is two characters, so it is two bytes,

CodePudding user response:

If you save a int I=567, you will find that is 3 bytes,
This is because you are save text way,
In text format, the system will use each number as a character (bytes)
Saved up 5 and 7 of the text of the three characters,

CodePudding user response:

We are talking of 4 bytes is refers to the memory, rather than a file.
  • Related