[英]C++ cout and endl not printing correctly on terminal
由於某種原因,我的 cout 語句無法在我的終端上正確打印。 它創造了空間。 當我有以下代碼時:
void Test::testSorted(){
vector<int> unsorted = {4, 6, 5, 2, 1, 3};
vector<int> sorted = {1, 2, 3, 4, 5, 6};
cout << "Testing isSorted function for unsorted Pancake ... : " << endl;
game.setPancakeStack(unsorted);
bool condition1 = game.isStackSorted();
cout << "Testing isSorted function for sorted Pancake ... : " ;
game.setPancakeStack(sorted);
bool condition2 = game.isStackSorted();
}
終端以精確的空間量精確輸出:
Testing isSorted function for unsorted Pancake ... :
Testing isSorted function for sorted Pancake ... :
注意:我一直在為一個項目使用 ncurses,我覺得這可能弄亂了我的外殼。 但我不知道去哪里解決這個問題
此症狀是 ncurses 應用程序未正確退出並使終端處於錯誤“模式”的教科書案例。 只需打開一個新終端即可修復它。
如果 ncurses 應用程序確實退出了,那么它在main
的末尾缺少一些去初始化(endwin()
?),這要么供您修復(如果您編寫應用程序),要么供您向開發人員報告(否則)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.