0
我有這樣一段代碼:不能糾正錯誤
static char szTop[] = "iMsg wParam lParam";
static char szUnd[] = "____ ______ ______";
static char szFormat[] = "%-16s%04X-%04X %04X-%04X";
static char szBuffer[50];
static HWND hwndButton[NUM];
,它給我的錯誤:
error C2143: syntax error : missing ']' before ';'
error C2143: syntax error : missing ';' before ']'
另一個代碼:
for(i=0;i<NUM;i++)
hwndButton[i] = CreateWindow ("button", button[i].text, WS_CHILD | WS_VISIBLE | button[i].style, cxChar, cyChar * (1+2*i), 20*cxChar, 7*cyChar/4, hwnd, (HMENU) i, ((LPCREATESTRUCT) lParam)->hInstance, NULL);
return 0;
而這給了我錯誤:
error C2146: syntax error : missing ')' before identifier 'i'
error C2059: syntax error : ';'
error C2059: syntax error : ')'
error C2146: syntax error : missing ';' before identifier 'hwndButton
我以前定義的所需事情:
static char szTop[] = "iMsg wParam lParam";
static char szUnd[] = "____ ______ ______";
static char szFormat[] = "%-16s%04X-%04X %04X-%04X";
static char szBuffer[50];
static HWND hwndButton[NUM];
static RECT rect;
static int cxChar,cyChar;
HDC hdc;
PAINTSTRUCT ps;
int i;
TEXTMETRIC tm;
我已經包含了windows.h,我試過包括windef.h但是沒有運氣,它仍然給出了錯誤 –
@rohit,還有一個其他的可能性,爲什麼'hwndButton'定義可能會失敗('NUM'不存在) - 我已經添加了答案。 – paxdiablo
我將NUM定義爲:#define NUM(sizeof button/sizeof button [0]); –