简体   繁体   中英

What is the other way to move on next line in C++ programming

One way to move on next line is cout << endl; I know there is another way to move on next line. But, I do not know what is that. Can anyone tell me.

You can write

std::cout << '\n';

instead. That would have the advantage that the stream isn't flushed at the same time.


Note:
On Windows OS it might be required to write

std::cout << '\r' << '\n';

or

std::cout << "\r\n";

to get correct line endings.

You can also use:

std::cout << '\n';

The only difference is that the stream won't be flushed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM