如何正确指定 goto 语句的标签?
How do I properly specify a label for the goto statement?
我在程序中使用了goto
语句。但是,当我尝试编译程序时,显示一条错误消息:expected primary-expression before ‘:’ token
。
#include <iostream>
using namespace std;
int main(void)
{
int num1, ans;
cout << "Please input a number: ";
cin >> num1;
if(num1 < 10)
goto tmp;
printf("Hello.n");
:tmp
printf("Worldn");
return 0;
}
冒号位于标签的另一侧,如下所示:
tmp:
printf("Worldn");
相关文章:
- 我的简单if-else语句是如何无法访问的代码
- 有一个打印语句的函数是一种糟糕的编程实践吗
- 线程,如果else语句,都是错误的上下文切换后,会发生什么
- 为什么是0;C++中的有效语句
- Insert函数不适用于2 if语句C++
- If语句未被求值C++
- C++嵌套if语句,基本货币交换
- 多个If语句与使用逻辑运算符计算条件的单个语句的比较
- 是否可以使用if constexpr删除控制流语句
- 无法理解此 return 语句的功能,没有它就会发生运行时错误
- 我似乎对if/else的基本语句有问题:/
- 当调用switch语句中的函数时(即使函数不包含循环),似乎是永不结束的循环的问题
- If语句在c++中被忽略
- 比较if语句中的数组值和int值
- C 和 C++ 中开关语句的案例标签的常量值,但显示不同的行为
- 如何正确指定 goto 语句的标签?
- 默认标签显然在 switch 语句中不起作用
- 为什么case语句中的标签应该是常量
- 可以定义一个带有goto语句和标签的宏吗
- 错误:跳转到switch语句中的大小写标签