[問題] 關於c++的multi threading編譯/執行問題

看板C_and_CPP作者 (JackyT)時間9年前 (2016/04/01 13:07), 9年前編輯推噓2(202)
留言4則, 3人參與, 最新討論串1/1
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) Linux 問題(Question): c++出現編譯錯誤 不確定是否是thread建立時的問題。 預期的正確結果(Expected Output): 輸入兩個數字,一個表示thread數量,一個表示要產生的隨機數字的個數 分配給不同thread加起來,印出每個thread的和以及main thread的和 錯誤結果(Wrong Output): http://i.imgur.com/tLCxwD3.jpg
程式碼(Code):(請善用置底文網頁, 記得排版) http://cpp.sh/6ioo6 補充說明(Supplement): 看不太懂編譯結果,求解QQ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.115.206.37 ※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1459487261.A.F05.html ※ 編輯: jackyT (140.115.206.37), 04/01/2016 13:22:39

04/01 14:10, , 1F
用g++ -m64 thread.cpp.......... 試試看?
04/01 14:10, 1F

04/01 14:14, , 2F
或g++ -m32 thread.cpp...
04/01 14:14, 2F
m64結果一樣 m32變成http://i.imgur.com/tC7Kq1t.jpg
不知道是什麼問題Orz ※ 編輯: jackyT (140.115.206.37), 04/01/2016 14:21:06

04/01 15:02, , 3F
string不能拿來跟int做相加
04/01 15:02, 3F
感謝C大 已解決<(_ _)>

04/01 15:08, , 4F
用g++不要用gcc吧 用gcc去編譯c++程式要考慮一堆link
04/01 15:08, 4F
感謝 g++編譯成功惹 ※ 編輯: jackyT (140.115.206.37), 04/01/2016 15:27:28 ※ 編輯: jackyT (140.115.206.37), 04/01/2016 15:31:52
文章代碼(AID): #1M_W8Ty5 (C_and_CPP)