[問題]用 array, struct, 和 qsort 做排序
開發平台(Platform): (Ex: Win10, Linux, ...)
Win 7
編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
Dev-C++ 5.11
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
問題(Question):
跟小弟之前問用 qsort 排序二維陣列類似, 只是這次換成排序 array 和 struct
想宣告一個 array, 元素都是 struct, 然後去做排序
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
prog.c: In function ‘compw’:
prog.c:7:12: error: dereferencing pointer to incomplete type ‘struct data’
return (p1->x) - (p2->x);
^~
prog.c: In function ‘comph’:
prog.c:13:12: error: dereferencing pointer to incomplete type ‘struct data’
return (p1->y) - (p2->y);
程式碼(Code):(請善用置底文網頁, 記得排版)
https://ideone.com/QjGEGU
補充說明(Supplement):
看不懂哪裡出問題, 麻煩大家幫忙解惑. 感恩
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 61.224.163.247
※ 文章網址: https://www.ptt.cc/bbs/C_and_CPP/M.1505141531.A.BCF.html
→
09/11 22:58, , 1F
09/11 22:58, 1F
→
09/11 22:59, , 2F
09/11 22:59, 2F
→
09/11 23:09, , 3F
09/11 23:09, 3F
→
09/11 23:10, , 4F
09/11 23:10, 4F
→
09/11 23:10, , 5F
09/11 23:10, 5F
→
09/11 23:11, , 6F
09/11 23:11, 6F
→
09/11 23:52, , 7F
09/11 23:52, 7F
推
09/11 23:53, , 8F
09/11 23:53, 8F
→
09/11 23:53, , 9F
09/11 23:53, 9F
→
09/11 23:54, , 10F
09/11 23:54, 10F