I haven't ever tried to apply the operator >> on a deferenced pointer to ifstream class object.
Try to see if passing by reference works. Also, by outputting the read text, check whether the strings are being read correctly. To not end-up in an infinite loop, apply a limitting condition as follows, just during the debugging.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
int countTextWords(ifstream& file)
int wordCount = 0;
unsignedint limit = 1000;
while ( ( file >> textWord ) && (limit--) )
// and in your main()
numWords = countTextWords( textFile );
Ahh I see. Coder777 you were right, I couldn't read anymore input through that ifstream object because the failbit was set after reading characters. Therefore I needed to clear the failbit before reading more input as ne555 pointed out.