无法理解 if 命令
cannot understand the if command
我正在尝试编写一个程序,当我键入load
时,该程序会在控制台中显示一条自定义消息。但我似乎无法让它工作。:/
#include "stdafx.h"
#include "iostream"
#include "string"
using namespace std;
int main()
{
int commands();
string text;
cout << "Write your registered e-mail to continue...n";
cin >> text;
string input;
cout << "n";
cout << "Welcome " << text << endl;
cout << "n";
cout << "www.steamcommunity.com/id/thetraderdazz> ";
cin >> input;
if (input = load);
cout << "loading...";
system("pause");
return 0;
}
它还给了我以下错误:
标识符"负载"未定义。
if (input = load);
这条线有三个错误。首先是您使用了赋值运算符=
而不是比较运算符==
。前者分配,后者比较。
第二个错误是你在括号后面放了一个分号,表示一个空的正文。编译器应该已就此发出警告。
最后,没有变量load
。你的意思是与字符串文字"load"
进行比较.
修复到
if (input == "load")
cout << "loading...n";
您可能打算执行以下操作
if (input == "load") {
cout << "loading...";
}
相关文章:
- 从命令行c++发送文本文件名
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 为cl.exe(Visual Studio代码)指定命令行C++版本
- 如何在OMNET++中指定与命令行参数组合的输出文件名
- 我的简单if-else语句是如何无法访问的代码
- 如何将enable-if与模板参数和参数包一起使用
- 无论条件是否为true,if总是在c++中执行
- Arduino:for/while/if在void setup()或void loop()之前?——错误:之前需要不合格
- 使用QProcess执行命令,并将结果存储在QStringList中
- 数组长度,为什么从命令行获取时不能使用它?
- Insert函数不适用于2 if语句C++
- If语句未被求值C++
- C++嵌套if语句,基本货币交换
- 多个If语句与使用逻辑运算符计算条件的单个语句的比较
- 是否可以使用if constexpr删除控制流语句
- 无法理解 if 命令
- 在 C++ 中使用 if(cin>>) 命令
- "if" 和"else if"命令在 C++ 中不起作用
- 我不能在VS 2013中使用if(ifs == NULL)命令
- c++ if命令读取为真,尽管为假