看板 C_and_CPP 關於我們 聯絡資訊
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) termios.h thread unistd.h 問題(Question): 我宣告了兩個thread物件 第一個不斷的輸出printf("1"); 第二個則是用自定義的getch()去監看輸入狀況 如果輸入a則停止程式、其餘的則輸出按下的值然後程式繼續 但是執行出來程式的output會卡在getch前 直到getch讀取到值以後才會把之前的output全部print出來 想問要如何做才能讓他不要等input...... 餵入的資料(Input): 預期的正確結果(Expected Output): 錯誤結果(Wrong Output): 程式碼(Code):(請善用置底文網頁, 記得排版) http://paste.plurk.com/show/2192424/ 補充說明(Supplement): 剛接觸thread如有觀念不對的地方 還請各位指教! 感謝大家m(_ _)m -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.113.123.74 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1435118477.A.AEE.html
PkmX: std::cout << std::flush; 06/24 13:24
sr29: 成功了O_O!! 06/24 15:05
sr29: 感謝!!! 06/24 15:05