c++ - C++编译错误

标签 c++

所以我刚开始学习基础知识,我尝试对数字做出响应,但它给了我第 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/

相关文章:

c++ - 编译 qt Creator/qt widget 示例时出错

c++ - 在 Linux 上的 C++ 源文件上运行 'gcc' 给出 "cc1plus: out of memory allocating ..."错误消息

c++ - 向数组移动和添加元素

c++ - 使用 libxml2 编写 Base64 编码的文本节点

C++ Stack实现为数组,程序崩溃

c++ - 将 int 转换为 base 2 cstring/string

带有静态成员的 c++ std::thread 挂起

c++ - 绕过 RTTI 的不同方法的优点

c++ - 如何在字符串 vector 中引用字符串的特定字符?

c++ - std::list 的 pop_back() 是否取消分配内存?