Miscellany
public text v1 · immutable#include <iostream>
#include <fstream>
using namespace std;
#include <string>
//Create Function
int countWords();
int countCharacters();
int main()
{
cout << countWords("txtdata.text");
return 0;
}
int countWords( string filename )
{
ifstream file( filename.c_str() );
int count = 0;
string temp;
while (file >> temp)
{
count = count + 1;
}
return count;
}