以下是统计单词个数代码,运行结果不对,请求解惑!
//使用一个char数组和循环来每次读取一个单词,直到用户输入done为止//然后,该程序指出输入了多少个单词(不包括done在内)
#include <iostream>
#include <cstring>
const int Number = 50;
const int Size = 10;
int main()
{
using namespace std;
char words[Number][Size];
int counts = 0;
cout << "Enter words (to top,type the word done): \n";
do
{
cin >> words[counts];
counts ++;
}while(strcmp(words[counts-1],"done") == 0);
cout << "You entered a total of " << counts << " words.";
return 0;
}