Student28
Student28

Reputation: 117

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.

Upvotes: 1

Views: 141

Answers (2)

RoiHatam
RoiHatam

Reputation: 896

You can also use:

std::cout << '\n';

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

Upvotes: 2

πάντα ῥεῖ
πάντα ῥεῖ

Reputation: 1

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.

Upvotes: 2

Related Questions