[问题] 开成专案以后标头档&全域变量问题

楼主: 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