c++的換行符怎么用?針對這個問題,這篇文章詳細介紹了相對應的分析和解答,希望可以幫助更多想解決這個問題的小伙伴找到更簡單易行的方法。
\n 換行,光標移到下一行的開頭;
endl,把緩沖槽的內容輸出到控制臺;
\r 回車,光標移到當前行的開頭,不會換到下一行,如果接著輸出的話,本行以前的內容會被逐一覆蓋;
#include <iostream> using namespace std; int main() { cout << "this is the first line\n"; cout << "this is the second line\r"; cout << "this is the third line\n"; cout << "this is the fouth line\r"; cout << "this is the fifth line\n"; cout<<"First"<<"\n"<<"Second"<<endl; cout<<"First123"<<"\r"<<"Second"<<endl; cout<<"這是換"<<endl<<"行符"; return 0; }
結果:
this is the first line this is the third linee this is the fifth line First Second Second23 這是換 行符 Presss any key to continue
關于c++的換行符怎么用問題的解答就分享到這里了,希望以上內容可以對大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關注億速云行業資訊頻道了解更多相關知識。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。