c - Why the byte are upside down? -


I have a "weird" issue with the C function fwrite . I have a Unsigned int is the indicator and I want to write it in a binary file, so I used the fwrite but the file is written inverted byte. For example, looking at FE 45 78 D4 4C E9 EA F1 etc., looking at unsigned int (4 bytes in my case), I see the file content As D4 78 45EFF1EAE94C etc. How can I fix this? A bit more information: When I say that bytes are written in the wrong order, I mean that every program I use to read the file Byte seeing the wrong sequence, error reading an error ... understand me Not only does the Fillit function use a different way to represent data ... More info: I tried

  fwrite (myuipointer, 4, size, file) ); Fwrite (myuipointer, 1, size * 4, file);   

The same result I also tried to use an unsigned four indicator which points to my data and writes it, no success ... "Post-text" itemprop = "text">

This is because your computer uses Little Endian storage semantics, which means that any number of small comes before the end. You are using numbers to see where the large end comes first (such as 340,000 , where thousands of columns come before the tens column.) < P> If your data will never be read on an older PowerPC Mac such as Large Endian system, then you can type your numbers in such a way, read them in the same system, and you can They will get them ordered correctly.

If you expect this data to be shared in different systems using different Andenance, then you should choose a byte order, paste it with it and / by file that byte order (Since you are not aware of the concept of endurance, I suspect it will not be in play for you.)

Comments

Popular posts from this blog

Python SQLAlchemy:AttributeError: Neither 'Column' object nor 'Comparator' object has an attribute 'schema' -

java - How not to audit a join table and related entities using Hibernate Envers? -

mongodb - CakePHP paginator ignoring order, but only for certain values -