All pastes #372696 Raw Edit

Anonymous

public text v1 · immutable
#372696 ·published 2007-02-26 07:11 UTC
rendered paste body

#include <iostream>
#include <fstream>
using namespace std;
#include <string>

//Create Function
int countWords(ifstream& num );
int countCharacters(ifstream& num );



int main(int countWords, int countCharacters)
{

	cout << "Found: " << countWords << " words." << endl;

	cout << "Found: " << countCharacters << " Characters" << endl;

	return 0;
}

int countWords(ifstream& num)
{
	ifstream myFile;
	myFile.open( "txtdata.txt" );
	int count = 0;
	string word;
	
	
	while (num >> word) 
	{
		count = count + 1;
	}
	
	return count;
}

int countCharacters(ifstream& num)
{
	ifstream myFile;
	myFile.open("txtdata.txt");
	int count = 0;
	char charcount;

	while ( num.get (charcount) )
	{
		count = count + 1;
	}
	return count;

}