小编yag*_*994的帖子

什么导致关于字符串的错误?

#include <iostream>
#include <string>

int main(void)
{
  using std::cout;
  using std::cin;
  using std::string;

  string name;
  int n1, n2;

  cout << "What is your name ?\n";
  cin >> name;
  cout << "Hello " << name.c_str() <<"!\n"
       << "Please give me two number separated by space\n";
  cin >> n1 >> n2;
  cout << "Sum of " << n1 << " + " << n2 << " is " << n1 + n2 << "\n";

  return 0;
}
Run Code Online (Sandbox Code Playgroud)

我的控制台输入/输出如下所示:

你叫什么名字 ?
约翰托特
你好约翰! …

c++ string

1
推荐指数
1
解决办法
84
查看次数

标签 统计

c++ ×1

string ×1