"Paul Pluzhnikov" wrote :
> Matt wrote:
>
> > What trick do I have to use to make the file contain exactly the data
> > I send to fwrite?
>
> Perhaps open the file in binary mode?
>
>   fopen("output", "wb");

To expand on that a little, under (most?) unixes, there is no difference 
between "text" and "binary" mode for files. In
Windows, however, reading a file opened in text mode converts \r\n (CR/LF pair) 
to \n, while writing does the converse -
i.e. \n gets written as \r\n - this is the extra byte you are seeing.

See:
http://new-brunswick.net/workshop/c++/faq/input-output.html#faq-15.12

and:
http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html#3

for more info.

Regards,

-- 
Lionel B

_______________________________________________
Help-gplusplus mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to