Every time I do 'cout << endl' or even 'cout << "\n"' and then launch my program under Windows to output to a file ("a.exe < test.in > result.out") I get "\r\n" line endings in "result.out".
Is there on earth a way to stop it doing so and just output "\n" on every 'cout << "\n"'?
Thanks in advance.
The cout object is used to display the output to the standard output device. It is defined in the iostream header file.
There is no std::cout in C. In a windowing system, the std::cout may not be implemented because there are windows and the OS doesn't know which one of your windows to output to. never ever give cout NULL. it will stop to work.
std::cout is used to output a value (cout = character output) std::cin is used to get an input value (cin = character input) << is used with std::cout, and shows the direction that data is moving (if std::cout represents the console, the output data is moving from the variable to the console).
This works using Visual Studio 2013:
#include <io.h>
#include <fcntl.h>
#include <iostream>
int main( int argc, char * argv[] )
{
_setmode( _fileno( stdout ), _O_BINARY );
std::cout << std::endl;
}
It will output only [0A], and not [0D][0A].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With