Hello,
I am a newbie in C++....I am trying to modify program to read in upto four words or 30 characters into a string and then print it out.
Here is the code.....
#include <iostream>
#include <conio.h>
using namespace std;
int main()
{
bool isWord = false;
char ch;
int wordCount = 0;
do {
ch = getche();
if (ch == ' ' || ch == '\r') {
if (isWord) {
wordCount++;
isWord = false;
}
}
else if (!isWord)
isWord = true;
} while (ch != '\r');
cout << "\nNumber of words typed: " << wordCount << endl;
system("pause");
return(0);
}
Please advice!