\n to \r\n in stdout

Ingo Krabbe ikrabbe.ask@web.de
Mon Nov 7 12:41:00 GMT 2005


This is no compiler problem but a problem of your system (Windows, Dos maybe, 
whose behaviour is to do such things).

You can try to change the terminal settings for the stdout line, which has a 
flag for such output postprocessings.  But such a discussion opens a vast 
area of misunderstandings.

Try to set the terminal parameters from your terminal instead.  This might 
help too.

Or just write directly to a file.

Use dup2 to duplicate your stdout descriptor and set some flags to write in 
binary mode to the descriptor might also help (never tried though).

Maybe fdopen(STDOUT_FILENO, "wb"), works too ?!

BYE INGO

Am Montag, 7. November 2005 13:09 schrieb thales@virtualbs.com.br:
> Hi all!
>
> I've looked at so many places that I'm thinking it won't have ways to
> resolve this problem. Then I remembered that exists this discussion list.
>
> So, here is my question:
>
> Please, but please... How can I prevent the compiler of substituting the
> character '\n' for the characters "\r\n"?
>
> I'm trying to open a binary file and print it to the stdout, but
> substituting '\n' for "\r\n", the file generated is corrupted.
>
> Thanks you all!
>
> Gratefully,
> Thales Medeiros.
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-help/attachments/20051107/2af76e39/attachment-0001.sig>


More information about the Gcc-help mailing list