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
- Next message: Karthik Kumar: "Re: Free open source IDE for C programming"
- Previous message: infobahn: "Re: initialize char string"
- In reply to: leonecla_at_yahoo.it: "Very strange problem using FWRITE() to write data to a binary file"
- Next in thread: Keith Thompson: "Re: Very strange problem using FWRITE() to write data to a binary file"
- Reply: Keith Thompson: "Re: Very strange problem using FWRITE() to write data to a binary file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Karthik Kumar: "Re: Free open source IDE for C programming"
- Previous message: infobahn: "Re: initialize char string"
- In reply to: leonecla_at_yahoo.it: "Very strange problem using FWRITE() to write data to a binary file"
- Next in thread: Keith Thompson: "Re: Very strange problem using FWRITE() to write data to a binary file"
- Reply: Keith Thompson: "Re: Very strange problem using FWRITE() to write data to a binary file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|