thinking in c++,练习2-3,编写一个程序用来打开文件并统计文件中以空格隔开的单词数目。
#include <iostream>
#include <string>#include <fstream>
using namespace std;
int main()
{
ifstream in("e://test.txt");
string word;
int num=0;
while(in>>word)
{
cout<<word<<" ";
num++;
}
cout<<endl<<num<<endl;
}