When newline in string is necessary, I use the \n
character
int main()
{
string str = "Hello world\n";
}
Is \n
crossplatform? Or do I need to use macro adapting it's value with the platform?
Especially when str
is going to be written to a file or stdout.
As long as you read/write text streams, or files in text mode, \n
will be translated into the correct sequence for the platform.
http://en.cppreference.com/w/c/io
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