 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
void CountChars()
|
|
|
// Counts the number of characters on one input line
|
|
|
// and prints the count Note: main() has already
|
|
|
// read the first character on a line
|
|
|
{
|
|
|
count = 0;
|
|
|
while (ch != ‘\n’)
|
|
|
{
|
|
|
count++;
|
|
|
cin.get(ch);
|
|
|
}
|
|
|
cout << count <<
“characters on this line.” << endl;
|
|
}
|
|