Mail Archives: djgpp/1996/08/25/02:11:52
Xref: | news2.mv.net comp.os.msdos.djgpp:7846
|
From: | "John M. Aldrich" <fighteer AT cs DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Getc(), putc() and feof() acting very wierdly
|
Date: | Sun, 25 Aug 1996 01:04:49 -0700
|
Organization: | Three pounds of chaos and a pinch of salt
|
Lines: | 26
|
Message-ID: | <32200921.2445@cs.com>
|
References: | <4vockq$ri5 AT nuntius DOT u-net DOT net>
|
NNTP-Posting-Host: | ppp220.cs.com
|
Mime-Version: | 1.0
|
To: | sam AT beavis DOT u-net DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Sam wrote:
>
> Now for my problem. I've written a very simple program to change the
> Windows wallpaper by copying one BMP to another. It randomly picks a
> BMP and copies it. Normally it works as expected, but a couple of
> files only copy the first few K, an 8578 byte file only gets to 1210
> bytes. It all exits as normal, and it all looks the most standard C I
> can write.
>
> which is about as simple as I can think of. Infile and outfile are
> both FILE * s, and are opened and closed with fopen and fclose as mode
> "r" and "w". ^^^^^^^^^^^^
This is your problem. Bitmaps are *binary* files, not text files. You
must open them with "wb" and "rb", respectively.
When a file is in text mode, the 'EOF' character is read as the end-of-
file marker, while in binary mode all characters are considered part of
the file.
--
----------------------------------------------------------------------------
| John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com |
| Proud owner of what might one day | Plan: To make Bill Gates suffer |
| be a spectacular MUD... | Tagline: <under construction> |
----------------------------------------------------------------------------
- Raw text -