Re: Problem writing to a file

From: Jerry Coffin (jcoffin_at_taeus.com)
Date: 01/16/04


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.


Relevant Pages

  • Re:
    ... back to 1.1 after the time bomb microsoft so kindly put in it. ... getting any error on my end, so I'm not sure what's causing it. ... but those throw different error messages. ... thing I know is that the error message occurs as soon as the .exe file ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Windows Update Error 80070005
    ... KenV replies with a working fix: ... > then tried to update again, but received the same error messages. ... > reinstall Service Pack 2, but cannot do that either now, and I get a message ... Anyone know what might be causing the problem with this ...
    (microsoft.public.windowsupdate)
  • Re: Add/remove Error Messages
    ... Im trying to unistall a bunch load of programs that are not needed and ... I want to go into add/remove programs but two ... What problems are these programs causing? ... What are the error messages you get when you try to remove them? ...
    (microsoft.public.windowsxp.help_and_support)
  • Re: eBay and Firefox - another problem
    ... anyone got any ideas what's causing all these error messages, ... where to look for further clues? ... satisfaction to block some of the junk they try to inflict upon me. ...
    (uk.people.consumers.ebay)
  • Re: Computer reboots suddenly
    ... Have a look in the Event Viewer for any 'Errors'. ... If you don't see any error messages, right click on My Computer, select ... Next time your PC reboots, ... Could the same thing be causing ...
    (microsoft.public.windowsxp.basics)