Results 1 to 2 of 2
So I am trying to create a function that is in a seperate file that will count words from a text file. I have the streams set up and it ...
- 02-06-2009 #1Just Joined!
- Join Date
- Feb 2009
- Posts
- 1
Help with C++ h/w on Counting Words
So I am trying to create a function that is in a seperate file that will count words from a text file. I have the streams set up and it is a pass by referance function so some variables are declared in the main program. I have been working on this for a couple days now and just can't seem to get it to work
. Below is the code for the function so if anyone has any suggestions please let me know thank you!!
#include <fstream>
#include <iostream>
using namespace std;
char WordCount(int& Word)
{
bool WordCheck = false;
char Tester;
ifstream in;
in.open("/export/home/wyatt/public_html/!Data/data244.txt");
in.get(Tester);
while(!in.eof())
{
if((Tester != ' ')||(Tester != '\t')||(Tester != '\n')||(Tester != 'endl'))
WordCheck = true;
else
WordCheck = false;
if(WordCheck == false)
Word ++;
in.get(Tester);
}
cout << "The total number of words in this text document are: " << Word;
return 0;
}
- 02-06-2009 #2
I'm sorry, we can't offer help on homework questions, as per the forum rules:
http://www.linuxforums.org/forum/lin...ums-rules.htmlRegistered Linux user #270181
TechieMoe's Tech Rants


