Mail Archives: djgpp/1998/11/07/13:15:22
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 -