我真的掙扎與這個問題了幾個小時:c指針問題。編譯器錯誤
char szKeyMap[MAX_ALPNUM_KEYS][CHAR_PER_KEY]= {"0- +%", "1QZ.\\", "2ABC&", "3DEF%", "4GHI*", "5JKL/", "6MNO~", "7PRS^", "8TUV[", "9WXY]", "*,'\":", "#=:$?" };
getkbd_entry(h_clock,insertPin,pinBuff,0,NUMERIC ,szKeyMap,sizeof(szKeyMap), 6 , 4);
和getkbd_entry原型爲:
int getkbd_entry(int h_clock, char *msg, char *outbuf, unsigned wait,
unsigned type, char szKeyMap[][CHAR_PER_KEY],
int KeyMapSize, int va_alist, ...);
我在編譯器獲取錯誤:
"C:\Bin\test.c", line 90: Warning: #167-D: argument of type "c
har *" is incompatible with parameter of type "signed char *"
getkbd_entry(h_clock,insertPin,pinBuff,0,NUMERIC ,szKeyMap,sizeof(szK
eyMap), 6 , 4);
^
"C:\Bin\test.c", line 90: Error: #167: argument of type "signe
d char (*)[6]" is incompatible with parameter of type "char *"
getkbd_entry(h_clock,insertPin,pinBuff,0,NUMERIC ,szKeyMap,sizeof(szK
eyMap), 6 , 4);
任何幫助非常感謝!
感謝
這是C代碼,對不起混淆 –
'CHAR_PER_KEY'是一個'#define'd常量嗎?我有點困惑,編譯器在第二個消息中將'char szKeyMap [] [CHAR_PER_KEY]'解釋爲'char *'。 –