March 30th, 2003, 09:19 PM
Join Date: Mar 2003
Time spent in forums: < 1 sec
Reputation Power: 0
Here is a very simple program that counts words and other things in a document. Some of this code I got help on. I am pretty new to C++ and I was wondering if someone can explain something to me. Here is the code:
int letters = 0, digits = 0, words = 0, puncts = 0, others = 0, average = 0;
cout<< "File not found!!! Exiting...........";
cout<< " File has been successfuly opened!";
while((isspace(ch) || isdigit(ch) || ispunct(ch)) && !txtdoc.eof())
while(isalpha(ch) && !txtdoc.eof())
average = (letters/double(words) + 0.5);
cout<< "Number of letters = " << letters << endl << endl;
cout<< "Number of digits = " << digits << endl << endl;
cout<< "Number of words = " << words << endl << endl;
cout<< "Number of punctuation characters = " << puncts << endl << endl;
My question is : how does it count the words? All I see is
but how does it tell words appart?
My second question is how to do the function of gotoxy (which positions the cursor at a given position on the screen) on dev.?
Thanks in advance;
Last edited by konradj : March 30th, 2003 at 09:28 PM.