Re: Problem writing to a file
From: Jerry Coffin (jcoffin_at_taeus.com)
Date: 01/16/04
- Next message: Arthur J. O'Dwyer: "Re: Is This How It's SUPPOSED to Work?"
- Previous message: Martijn Lievaart: "Re: [C++] Vector - guaranteed to be contiguous?"
- In reply to: Peter Venis: "Problem writing to a file"
- Next in thread: Leor Zolman: "Re: Problem writing to a file"
- Reply: Leor Zolman: "Re: Problem writing to a file"
- Reply: Peter Venis: "Re: Problem writing to a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 16 Jan 2004 16:31:50 GMT
In article <sFANb.182097$_x2.367894@zonnet-reader-1>,
petervenis@zonnet.nl says...
> Hi,
>
> I'm creating a small font library and for that I need to write some data to
> a file. The file only conststs of three parts, a header, a lookup table and
> some pixel data which is loaded from a raw greyscale image file, the data
> has the following sizes:
>
> Header: 10 bytes
> Lookup Table: 94*3 = 282 bytes
> Pixel Data: 256*128 = 32768 bytes
>
> Total: 33060 bytes
>
> The program runs fine and does not return any error messages, strangely, the
> file that is created is 33077 bytes and not 33060. I have no idea what might
> be causing this error. Here is my complete code. A small bit of it is
> windows related but I don't think that is relevant to the cause so I post
> this topic here:
You have two separate issues: one is structure padding, which has
already been discussed (to at least some extent).
The second is that you're writing what looks like binary data, but
you're opening the file in text (translated) mode. Given that you're
working with non-text data, you should open the input file with a mode
string of "rb" and the output file with a mode string of "wb".
--
Later,
Jerry.
The universe is a figment of its own imagination.
- Next message: Arthur J. O'Dwyer: "Re: Is This How It's SUPPOSED to Work?"
- Previous message: Martijn Lievaart: "Re: [C++] Vector - guaranteed to be contiguous?"
- In reply to: Peter Venis: "Problem writing to a file"
- Next in thread: Leor Zolman: "Re: Problem writing to a file"
- Reply: Leor Zolman: "Re: Problem writing to a file"
- Reply: Peter Venis: "Re: Problem writing to a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|