这里需要吧string.h包含进来
#pragma region charChangStr.cpp
//程序清单4.4
// 2.修改程序清单 4.4,使用 C++ string 类而不是 char 数组。
//函数:getline()
#if 1
#include <iostream>
#include <string>
int main()
{
using namespace std;
string name;
string dessert;
cout << "Enter your name:\n";
getline(cin,name); //reads through newline
cout << "Enter your favorite dessert:\n";
getline(cin,dessert);
cout << "I have some delicious " << dessert;
cout << " for you, " << name << ".\n";
return 0;
}
#endif
#pragma endregion
上面代码运行OK
504

被折叠的 条评论
为什么被折叠?



