Re: Problem writing to a file

From: Peter Venis (petervenis_at_zonnet.nl)
Date: 01/16/04


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.



Relevant Pages

  • Re: [bug] ata subsystem related crash with latest -git
    ... avoid a higher order allocation. ... this one finally made the trick and it's booting fine now, ... I did manage to capture the error messages this time, and in the two machines I'm actively testing on, sata_mv is the driver that's dying in both cases. ...
    (Linux-Kernel)
  • Re: kernel source and gcc-4.0
    ... Jerome BENOIT told: ... > thanks for the trick. ... > but unfortunately I still get the same error messages: ... be a means to conceal oneself." ...
    (Debian-User)
  • Re: Cannot access shares
    ... but adjusting irpstacksize does not do the trick. ... > do give different error messages, ...
    (microsoft.public.windowsxp.general)
  • Re: Xprint startup errors
    ... >> Did you refresh fonts.scale and then font.dir? ... >> usually does the trick for me ... Still get the error messages. ... To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org ...
    (Debian-User)
  • Re: how to stop mail() errors going to postmaster@etc...?
    ... > Thanks Pedro, ... > That seems to have done the trick. ... it seems to just copy the error messages to ... Is there a way to stop the Postmaster getting these messages? ...
    (comp.lang.php)