[問題] 請問一下cout.flush()

看板C_and_CPP (C/C++)作者 (PF)時間16年前 (2009/10/30 15:52), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/1
( *[1m *[m 為色碼,可以按 Ctrl+V 預覽會顯示的顏色 ) ( 未必需要依照此格式,文章條理清楚即可 ) 遇到的問題: (題意請描述清楚) 因為我想寫個可以顯示現在跑到那裡的程式 但是跑出來的結果很怪... 為什麼跑出來的後面都會多一串數字勒.... 想請大大們幫我一下 <(_ _)> 開發平台: (例: VC++ or gcc/g++ or Dev-C++, Windows or Linux) g++ , linux 有問題的code: (請善用置底文標色功能) #include <iostream> using namespace std; int main() { int a = 0; int i = 0; cout << "Show Now:\n\n"; for (; a <= 1000000;a++) { for ( i = 0; i <= 100000;i++ ) ; cout.flush(); for ( i = 0; i <= 20; i++ ) cout << "\b"; if ( a % 1000 != 0 ) { cout << "Now : " << a; } else if ( a % 1000 == 0 && a > 0 ) { int j; cout << a << endl; } a++; } return 0; } 補充說明: -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.45.102.96
文章代碼(AID): #1Awfi_oj (C_and_CPP)
文章代碼(AID): #1Awfi_oj (C_and_CPP)