令牌之前'||'预期主表达式出错

Error expected primary-expression before '||' token

本文关键字:表达式 出错 令牌      更新时间:2023-10-16

目前试图完成我的c++分配,代码还不完整,但我只是试图编译它,我遇到了这个错误。我似乎不知道如何修复它,任何指针?请原谅这个超级菜鸟的问题…我还是入门课程的初学者。

代码

你的括号乱了。c++中的if语句条件应该像这样用圆括号括起来:

if ( animal == 'D' || animal == 'd' )...
if ( status == 'Y' || status == 'y' )...
else if ( status == 'N' || status == 'n')...

你的条件必须用单括号括起来

if ((animal == 'D') || (animal == 'd'))

,

if((status == 'Y) || (status == 'y))

,

else if((status == 'N') || (status == 'n'))

你的If语法错了,亲爱的。你漏掉了圆括号。应该是:

if((status == 'N') || (status == 'n'))