[問題] 開成專案以後標頭檔&全域變數問題

作者: defsrisars (阿轉)   2014-12-19 12:39:10
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
DevC 5.8.2
問題(Question):
小的最近初學C語言
目前大一在做C語言實習課的期末作業
但有些問題上網看了許久還是找不太到答案QQ
(像extern 結構避免重複宣告也是上網看了很久才知道)
希望有大大能夠不吝指導一下
1. void Deal_First(int *card,Player *P,int *flag);
這一行會跑出編譯訊息
[Note] expected 'int *' but argument is of type 'int (*)[52]'
想請問是什麼意思呢? int * 跟 int(*) 是差在哪QQ
我呼叫的地方是這樣寫的
Deal_First(&card,A,&flag);
其中card跟flag是宣告int
A是用malloc做出指向結構Player(我有typedef了)的指標
struct player * A = (struct player*)malloc(sizeof(struct player));
2. 然而最主要的錯誤是出在
14 34 C:\Users\PC\Desktop\期末專題Dev\Deal_First.c [Error]
'flower_table' undeclared (first use in this function)
14 64 C:\Users\PC\Desktop\期末專題Dev\Deal_First.c [Error]
'number_table' undeclared (first use in this function)
也就是下方程式碼的78行
我看起來的認知是compiler覺得我的flower_table跟number_table沒有宣告
但是我5~8行宣告不是應該在main.c裡面宣告為全域變數了嗎?
(我專案應該開的沒問題~都有連結到,這行//就可以執行了)
另外就是想請問有沒有辦法把這個5~8行放進標頭檔(全域變數放進標頭檔?)
然後又像extern結構的用法一樣不要重複宣告呢?
然後如果有哪裡是很爛的寫法該做修改請告訴我謝謝QQ
謝謝大家QQ
p.s 程式碼只放部份 main.c 標頭檔H.h 跟出問題的函式
預期的正確結果(Expected Output):
程式能正常運行
程式碼(Code):(請善用置底文網頁, 記得排版)
http://codepad.org/B41FXz3N

Links booklink

Contact Us: admin [ a t ] ucptt.com