9.编写一个满足前一个练习中描述的程序,
但使用 string对象而不是字符数组。请在程序中包含头文件 string,
并使用关系运算符来进行比较测试。
#pragma region 第五章练习9
#if 1
#include<iostream>
#include <string>
int main()
{
using namespace std;
const string const szDone = "done";
int cntWord = -1;
string szWorld;
do
{
cntWord++;
cin >> szWorld;
} while (szDone != szWorld);
cout << "You entered a total of " << cntWord << " words." << endl;
return 0;
}
#endif
#pragma endregion
string 类进行比较的话,直接就判断了,不需要用strcmp函数
600

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



