holeMenuProgram.cpp:38:1 错误:'}'令牌之前的预期主表达式
holeMenuProgram.cpp:38:1 Error: Expected Primary-Expression before '}' token
我正在使用开关大小写创建一个菜单,但是当我使用 do-while 语句过滤掉不可用的选项时,我遇到了一个奇怪的错误。我能了解一下我在这里做错了什么吗?提前感谢您,因为我是一名新程序员。我知道大小写开关中没有任何内容,但这不应该阻止它正确编译。
//Programmer: Lane Floyd Date: 2/17/2020
//File: holeMenuProgram.cpp
//Description:
#include <iostream>
using namespace std;
int main()
{
int menuChoice; //User input 1-4 for menu choice.
do
{
// Below is the menu.
cout << " Menu " << endl;
cout << " ---- " << endl;
cout << "1. Enter a number " << endl;
cout << "2. Power the number " << endl;
cout << "3. Cube root of the number " <<endl;
cout << "4. Quit" <<endl;
cout << "Input Choice: r";
cin >> menuChoice;
} while (menuChoice != 1 || menuChoice != 0);
switch(menuChoice)
{
case 1:
case 2:
case 3:
case 4:
}
return 0;
}
标签必须位于语句之前。你可以写例如
switch(menuChoice)
{
case 1:
case 2:
case 3:
case 4:
;
}
在 switch 语句的右大括号之前放置一个 null 语句。
或者为了使代码更具可读性,您可以插入至少一个中断语句,例如
switch(menuChoice)
{
case 1:
case 2:
case 3:
case 4:
break;
}
相关文章:
- holeMenuProgram.cpp:38:1 错误:'}'令牌之前的预期主表达式
- (错误:令牌之前'<<'预期的主表达式)
- 错误:C++中']'令牌之前的预期主表达式
- 错误:令牌之前的预期主表达式'&&'
- 令牌之前']'预期的主表达式?
- 错误:令牌之前的预期主表达式'/'
- 正则表达式使用提升令牌迭代器在单引号和括号之间提取值
- 令牌之前')'预期的主表达式(需要"template"消除歧义器)
- 错误:令牌之前的预期主表达式'<':Arduino RGB 舞灯
- 令牌之前出现错误')'主表达式
- C++错误:错误:令牌之前的预期主表达式'||'
- 令牌问题之前'*'预期的主表达式
- 令牌之前的预期表达式']'?C
- 退出状态 1 令牌之前的预期主表达式'.'
- C++错误:";"之前应为主表达式使用Cmake的令牌
- 向量空Push_back在令牌之前调用'{'预期的主表达式
- 令牌调用之前'...'预期的主表达式 模板化类的模板化方法
- 错误 预期主表达式在 ';" 之前令牌 C++
- 令牌之前的预期主表达式'-'
- 令牌之前的预期主表达式'<'