编写一个程序,它使用一个char数组和循环来每次读取一个单词,直到用户输入done为止。随后,该程序指出用户输入 了多少个单词(不包括done在内)。下面是该程序的运行情况
#include <iostream>
#include <cstring>
int main()
{
using namespace std;
const int ArSize = 20;
char ch[ArSize];
int count = 0;
cout << "Enter words (to stop,type the word done: \n";
cin >> ch;
while(strcmp(ch,"done")!=0)
{
//cout << ch;
count++;
cin >> ch;
}
cout << endl << count << " words read\n";
return 0;
}