gpt4 book ai didi

c++ - C++编译错误

转载 作者:行者123 更新时间:2023-11-28 00:09:49 25 4
gpt4 key购买 nike

所以我刚开始学习基础知识,我尝试对数字做出响应,但它给了我第 10 行和第 13 行的“std::”绑定(bind)错误。这是代码(P.S 我认为最后一个大括号落在后面):

#include <iostream>
#include <string>

using namespace std;

int main() {
string name;
int FavNum;
cout << "Hello Sir what is your name" << endl;
cin >> name >> "\n";

cout << "Well Hello " << name
<< "What is your Favorite number between 1 and 100" << endl;
cin >> name >> "\n";
if (FavNum > 100) {
cout << "Wow you like big numbers, but sorry you cant use that one" << endl;
} else if (FavNum >= 90) {
cout << "Wow you like huge numbers!" << endl;
} else if (FavNum <= 10) {
cout << "Wow you like smaller numbers!!!" << endl;
} else if (FavNum == 13) {
cout << "Wow your favorite number is the most unluckiest number in the "
"whole entire universe and I don't know many people that would "
"choose this number I'm proud comrad"
<< endl;
} else if (FavNum <= 89) {
cout << "You have a very nice number thats average try again!" << endl;
}
}

最佳答案

cin >> name >> "\n";

应该是

cin >> name;

您在这两个地方都使用了它。您不能将输入流发送到字符串文字。

关于c++ - C++编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33747468/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com