There was a problem reading the file. Correctly open the required file with the attributes "rb" through the standard function fopen. Reading occurs through:
char ch = getc(input_file); In the environment through sizeof(char) check that this type occupies 8 bytes. It works incorrectly...
It turns out (using printf ) that from time to time (or, rather, stochastically) the next byte is read completely incorrectly. Below I give a "raw" binary dump of a file in the Little-Endian format, and next to it are the values that the corresponding function "spits out" to me, with offsets
Смещение Исходное значение (LE) Показываемое значение (LE) 0x100 73 00 00 00 73 00 00 00 0x204 00 7D 00 00 00 7D 00 00 0x208 CE 03 00 00 FFFFFFCE 03 00 00 0x20C EB 09 00 00 FFFFFFEB 09 00 00 0x210 05 00 00 00 05 00 00 00 0x214 C7 3A CE 3F FFFFFFC7 3A FFFFFFCE 3F 0X318 CE 80 00 00 FFFFFFCE FFFFFF80 00 00 0X31C 12 01 00 00 12 01 00 00 0X320 F2 01 00 00 FFFFFFF2 01 00 00 0X324 05 00 00 00 05 00 00 00 0X328 C7 3A CE 3F FFFFFFC7 3A FFFFFFCE 3F As far as I can tell, the system is as follows: if the number read ( char ch ) is less than 0x80, then it "remains" the same as it was, and if it is greater or equal, then in some way (which one, I am very interested) " finishes "up to 32 (bit depth x86?)" from the left "units ...
It is also interesting that I read the whole thing into a two-dimensional array of char arr[][] , and then pass and so on ... But why compile this way, if sizeof(char) == 1 ?!
In the end, what to do with the program? don't use the same mask every time when char ch >= 0x80 ? What will be more effective and correct, or how can you completely avoid this whole thing?
Thanks in advance for your answers!
Just in case:
Language: Clean C
IDE: C-Free Professional 5.0 + mingw5
FFFFFFC7cannot be a byte value. Yes, and do not forget thatprintfas a variadic function extends its char parameters toint'a. Tried just to draw inunsigned char? Dkmayu, the problem is not in reading, but in the conclusion. - VladD