Re: Very strange problem using FWRITE() to write data to a binary file

From: Villy Kruse (vek_at_station02.ohout.pharmapartners.nl)
Date: 02/09/05


Date: 09 Feb 2005 08:14:57 GMT

On 8 Feb 2005 08:35:12 -0800,
    leonecla@yahoo.it <leonecla@yahoo.it> wrote:

> ....
> {
> w = 0x17070707;
> fwrite(&w, sizeof(w), 1, f_out);
> fclose(f_out);
> }
> }
> ---------------------------------------------
>
> If I execute this code (compile with Visual Studio 6) and then open the
> "data_8bit.bin" file (inside the Visual Studio), it is displayed as a
> binary file, and I can see the data "07 07 07 17". It is correct.
> Now, if in the code above I assign to w the value 0x07070707 (instead
> of 0x17070707), execute the code and open the "data_8bit.bin", it
> contains no more binary data...

Not strange at all. Keyword here is "little endian", where the least
significant byte of a multibyte integer is stored at the lowest memory
address, that is, occurs first in the disk file.

Villy



Relevant Pages

  • Re: maintaining state with sessions - help
    ... leegold2 wrote: ... I'm getting strange results from my GET - imo I should start ... >> the user is conducting multiple keyword searches at the same time. ... >> session would cause the subsequent pages of search results to use ...
    (comp.lang.php)
  • Re: [PATCH 1/9] lib/vsprintf.c: Add %pU to print UUID/GUIDs
    ... I think the whole %pmechanism is strange and takes ... %pUl: lower case little endian ... %pUB: upper case big endian ...
    (Linux-Kernel)
  • Re: Unable to obtain a handle to a graph legend
    ... I made the mistake of using 'set' as a variable name. ... Strange that Matlab does not warn you when you are using a ... SET is not a keyword, ... That's one of the reasons I tend to use k as my loop ...
    (comp.soft-sys.matlab)
  • Re: Opening binary data from MSVS under linux
    ... I'm trying to open under linux, but the format seems to be very strange ... (doesn't seem to be neither big endian nor little endian). ... try using a longer string of hex integers. ...
    (Debian-User)
  • follow up to upper lower case differences.
    ... of you (especially Roy) might be interested in the ... strange results I am seeing. ... it in the serps when I search for the keyword ... it is targeting. ...
    (alt.internet.search-engines)