Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: C++: 「std::endl」と「\n」
newline を印刷するこれら2つの方法に大きな違いがあるかどうか疑問に思っています:
cout << endl; //approach1 cout << "\n"; //approach2
実用的な違いはありますか?
はい、違います。
"\n"stdout に追加される長さ 1 の単なる文字列です。
"\n"
std::endl"\n"代わりに、改行文字 ( ) を追加し、stdout バッファーをフラッシュするオブジェクトです。このため、より多くの処理が必要になります。
std::endl