The Windows console follows the same line termination convention that is assumed for files, or, equivalently, for real physical terminals. He should see that CR and LF should move correctly to the next line.
However, there is a lot of software infrastructure between ANSI C and this console. In particular, any standard C library I / O function will try to do the right thing, assuming you let it get a chance. This is why the fopen() t and b modifiers were defined for the mode parameter.
With t (by default for most threads, and in particular for stdin and stdout ), any printed \n converted to a CRLF sequence, and the opposite happens for reading. To disable this behavior, use the b modifier.
By the way, terminals traditionally connected to * nix blocks, including the DEC VT100 emulated by XTerm, also need CR and LF. However, in the * nix world, conversion from a newline to a CRLF sequence is processed in the tty device driver, so most programs do not need to know about it, and t and b modifiers are ignored. On these platforms, if you need to send and receive characters to tty without this modifications, you need to look for stty (1) or the system calls it depends on.
If your ANSI C program otherwise avoids the C library I / O (perhaps because you need access to the console character color and other attributes), then whether you need to send CR or not will depend on which Win32 API calls you use to send characters.
RBerteig
source share