Re: Problem writing to a file
From: Peter Venis (petervenis_at_zonnet.nl)
Date: 01/16/04
- Next message: Erik Jälevik: "Using vectors as arrays"
- Previous message: Jerry Coffin: "Re: Is This How It's SUPPOSED to Work?"
- In reply to: Jerry Coffin: "Re: Problem writing to a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 16 Jan 2004 20:09:25 +0100
Big thanks, the "rb" and "wb" did the trick.
It has happened before that I'm getting so desperate that I start to blame
the OS or think it's a compiler bug. But of course, it always turns out to
be me.
Peter
"Jerry Coffin" <jcoffin@taeus.com> schreef in bericht
news:MPG.1a71c10973ae541989c14@news.clspco.adelphia.net...
> 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: Erik Jälevik: "Using vectors as arrays"
- Previous message: Jerry Coffin: "Re: Is This How It's SUPPOSED to Work?"
- In reply to: Jerry Coffin: "Re: Problem writing to a file"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|