[問題] pthread一點小問題

看板C_and_CPP (C/C++)作者 (人間失格)時間13年前 (2012/10/13 16:43), 編輯推噓0(005)
留言5則, 4人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) linux 額外使用到的函數庫(Library Used): (Ex: OpenGL, ...) #include <pthread.h> 問題(Question): 給一個數字 然後用thread印出<=他的所有質數 餵入的資料(Input): 7 預期的正確結果(Expected Output): 2 3 5 7 錯誤結果(Wrong Output): 啥都沒出現QQ 程式碼(Code):(請善用置底文網頁, 記得排版) http://codepad.org/XKthHkQi 補充說明(Supplement): 只差一行printf("\n"); 就決定印不印的出答案OAO 感謝!!: ) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.114.86.206

10/13 17:53, , 1F
man flush/fflush?
10/13 17:53, 1F

10/13 21:50, , 2F
printf 好像沒有換行就不會清空緩衝區將資料寫出來
10/13 21:50, 2F

10/14 00:01, , 3F
因為stdout是line buffered
10/14 00:01, 3F

10/14 08:16, , 4F
原來如此!!我了解了!!!
10/14 08:16, 4F

10/14 08:18, , 5F
感謝!!
10/14 08:18, 5F
文章代碼(AID): #1GUIckjq (C_and_CPP)
文章代碼(AID): #1GUIckjq (C_and_CPP)