delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/07/13:15:22

From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: ios::binary ignored by GCC - HELP!
Date: Sat, 07 Nov 1998 12:29:38 -0500
References: <fycflpbqrpbz DOT f2134e0 DOT pminews AT nntp DOT generation DOT net> <7208uh$epn$1 AT news DOT luth DOT se> <fycflpbqrpbz DOT f21i3u0 DOT pminews AT nntp DOT generation DOT net>
Organization: Nocturnal Aviation
X-Posted-Path-Was: not-for-mail
X-Accept-Language: en
Mime-Version: 1.0
Lines: 29
NNTP-Posting-Host: 1cust116.tnt12.nyc3.da.uu.net
X-ELN-Date: Sat Nov 7 09:45:20 1998
X-Mailer: Mozilla 4.5 [en] (Win95; I)
Message-ID: <36448382.68F2FAFF@earthlink.net>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

sl wrote:
> 
> On 7 Nov 1998 01:49:05 GMT, Martin Str|mberg wrote:
> 
> >: does one go about fixing this?
> >
> >Try "fprintf(f, "%c", 7);" or the equivalent in C++ (I don't know
> >C++).
> 
>         But then what happens when/if I try to write "int" to the file? All
> it really requires is two bytes, but GCC writes it out as its text
> counterpart for some reason..

Gill, it is not just gcc.  All C and C++ compilers treat requesrs for
formatted ouput (*printf()) as requests for formatted output.  If you
have an object of type T that you want to write to a stream s:

#include <stdio.h>
T object;
FILE *s;
/* ... */
fwrite(&object, sizeof object, 1, s);
   /* or */
fwrite(&object, sizeof(T), 1, s);


-- 
Martin Ambuhl (mambuhl AT earthlink DOT net)
Note: mambuhl AT tiac DOT net will soon be inactive

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019