需要 C++ 语法错误帮助,'}'之前缺少';'
c++ syntax error help needed, missing ';' before '}'
else if((RI >= 181) && (RI <= 210)){
if((ICT1 = false) || ((ICT2 = false) || (ICT3 = false))){
cout << "ICT n";
if(ICT1 = false){
ICT1 = true;
goto endICT;
}
if(ICT2 = false){
ICT2 = true;
goto endICT;
}
if(ICT3 = false){
ICT3 = true;
goto endICT;
}
endICT:
}
你好!这只是我程序的一部分,这段代码出现了几次,有不同的变量和其他东西。当我编译代码时,我得到"错误C2143:语法错误:在'}'之前缺少';'"我是新的所有这些编码,并将感谢任何帮助!谢谢你的时间!编辑:对不起,我之前没有包含足够的代码!基本上是随机选择一个数字,如果它在一个范围内,它就会经过这一部分。这个范围只能被选择3次,因为第一个"if"将不为真。谢谢你到目前为止的帮助!错误也在'endICT:'行。
插入一个空语句:
if(ICT3 = false){
ICT3 = true;
goto endICT;
}
endICT: ;
}
首先注意,使用goto
语句被认为是一种不好的做法。只有在没有其他选择的情况下才能使用。
这段代码还有一些其他的东西。我在代码
中注释了一些if(ICT3 = false) //this will assign value false into variable ICT3
//you might want to write if(ICT3 == false) to compare and execute
{
ICT3 = true;
goto endICT; //this goto statement is completely redundant
}
//I assume that you want to have some code here, that does not execute
//if ICT3 == false in the first place... You should use if() ... else
//statement instead
endICT: ; //You are missing some ; here should be enough
}
有关C/c++中流控制语句的更多信息,请访问此处。有关C/c++中操作符的更多信息,请参考
编译器可能与您的标签混淆了endICT:
这在语义上等同于您发布的代码:
else if ( RI >= 181 && RI <= 210 )
{
cout << "ICT n";
if ( ! ICT1 )
ICT1 = true;
else if ( ! ICT2 )
ICT2 = true;
else if ( ! ICT3 )
ICT3 = true;
}
相关文章:
- 需要帮助设置在C++中使用的Potrace
- 在指针的帮助下,文本文件中单词的频率
- 计算每个节点的树高,帮助我解释这个代码解决方案
- 如何在Qbutton的帮助下更改Q对话框的宽度
- 需要帮助将结构数组传递给函数
- C++需要帮助从用户那里获得一个整数,并确保它在另外两个整数之间
- 需要帮助在 c++ 中将字符串转换为字符 ----错误 "const char *" 类型的值不能用于初始化 "char" 类型的实体
- 有人可以帮助我处理正则表达式吗?
- C++调用具有 *this 属性的单个帮助程序函数
- C++:需要帮助了解运算符重载错误
- 需要以下代码的帮助,下面的代码有什么问题
- CS1 项目帮助C++
- 用于检查值是否为其任何参数的帮助程序函数
- 需要有关此 if 语句的帮助
- 类型限定宏帮助程序
- CoreCLR 中的检测探查器 - 将帮助程序程序集加载到 dotnet 进程的方法
- NS3 插槽混淆(需要帮助理解)
- 设计帮助 - 为不同类型的消息处理通用接口的设计模式
- 需要帮助查找内存泄漏
- 有人可以帮助我理解这些参数/参数吗?