作者icedwater (艾斯萊特)
看板C_and_CPP
標題[問題] 求救,關於C的pthread問題
時間Sat Nov 7 01:46:52 2015
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
Dev C++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
pthread.h
問題(Question):
學校作業要求用pthread實作任何一種sort,我原本在全域變數的地方宣告好
一個陣列的話(註解部分)可以好好的完成sort,但是變成用指標建成陣列的話
就不能好好排列了,想請問各位前輩們問題是出在哪裡呢?難道是指標不能宣告
在全域嗎?麻煩了,不好意思><
餵入的資料(Input):
18
20 5 99 84 68 52 45 65 3 2 22 84 98 94 76 11 9 7
預期的正確結果(Expected Output):
2 3 5 7 9 11 20 22 45 52 65 68 76 84 84 94 98 99
錯誤結果(Wrong Output):
5 20 99 84 68 52 45 65 3 2 22 84 98 94 76 11 9 7
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/caxd5i9l
補充說明(Supplement):
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.231.113.60
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1446832015.A.28F.html
推 aiwhat: ai.high錯了,直接用 sum-1 就好 11/07 04:43
→ aiwhat: sizeof(a) 回傳的是 sizeof(int*) 11/07 04:44
→ aiwhat: 可以參考上面那篇的回答 11/07 05:25