請在下面找到我的函數C.我在那裏使用一個堆棧,它是另一個文件的一部分,但它工作正常。error:expected')'before';'或'}'token
void doOperation (tStack* s, char c, char* postExpr, unsigned* postLen) {
if ((c == ('*' || '\')) && (s->arr[s->top] == ('+' || '-')))
stackPush(s, c);
else if (c == ('+' || '-') && s->arr[s->top] == ('*' || '/')) {
stackTop(s, postExpr[postLen]);
*(postLen)++;
stackPop(s);
stackPush(s, c);
}
else if (c == '(')
stackPush(s, c);
else if (c == ')')
untilLeftPar(s, postExpr, postLen);
else {
stackTop(s, postExpr[postLen]);
*(postLen)++;
stackPop(s);
stackPush(s, c);
}
}
我得到這些錯誤,我不知道什麼是錯的:
c204.c:70:23: warning: character constant too long for its type [enabled by default]
c204.c:70:58: warning: multi-character character constant [-Wmultichar]
c204.c:70:65: warning: missing terminating ' character [enabled by default]
c204.c:70:2: error: missing terminating ' character
c204.c:71:3: error: void value not ignored as it ought to be
c204.c:71:19: error: expected ‘)’ before ‘;’ token
c204.c:88:1: error: expected ‘)’ before ‘}’ token
c204.c:88:1: error: expected ‘)’ before ‘}’ token
c204.c:88:1: error: expected expression before ‘}’ token
../c202/c202.c: In function ‘stackTop’:
../c202/c202.c:100:18: warning: the comparison will always
evaluate as ‘true’ for the address of ‘stackEmpty’ will never be NULL [-Waddress]
../c202/c202.c: In function ‘stackPop’:
../c202/c202.c:120:18: warning: the comparison will always
evaluate as ‘true’ for the address of ‘stackEmpty’ will never be NULL [-Waddress]
../c202/c202.c: In function ‘stackPush’:
../c202/c202.c:133:17: warning: the comparison will always
evaluate as ‘false’ for the address of ‘stackFull’ will never be NULL [-Waddress]
make: *** [c204-test] Error 1
什麼可能是這些錯誤的原因是什麼?
我不知道你在用什麼來編輯你的代碼,但在這種情況下,語法突出顯示是一個相當不錯的指示,說明哪裏出了問題。並且不要跳過編譯器錯誤中的項目。您關注的是預期的令牌錯誤,其中第一個實際錯誤(以及之前的警告)實際上是問題的更好指標。 – Bart
甚至StackOverflow上的語法突出顯示也會捕獲它...... – wildplasser