sentinel-controlled while loop

#include <iostream>

using namespace std;

int main()
{
//varible declaration
char letter;
int counter;

cout <<"\nStart to get character..."<<endl;
// Read the first character
cin.get(letter); // Notice get function for reading white spaces
counter = 0; // Initialize the counter
while( ) // Test if letter is end-of-line character
{
// check for non-white character: add operators to the following line
if((letter __ ' ') __ (letter __ '\t'))
________________________ //Increment counter
________________________ //Read the next character
}
cout <<"\nThe number of charater is "<< counter << endl;

cout <<"\nFinish running"<<endl;
return 0;


This is what i did, and i am new to this so please help me out here.

// Read the first character
cin.get(letter); // Notice get function for reading white spaces
counter = 0; // Initialize the counter
while(!letter.eof()) // Test if letter is end-of-line character
{
// check for non-white character: add operators to the following line
if((letter != ' ') __ (letter __ '\t'))
++counter; //Increment counter
______cin >> letter;__________________ //Read the next character
}

1170_7_4b.cc:24: error: request for member 'eof' in 'letter', which is of non-class type 'char'
1170_7_4b.cc:27: error: expected ')' before '__'
1170_7_4b.cc:29: error: '______cin' was not declared in this scope
1170_7_4b.cc:29: error: '__________________' was not declared in this scope
1170_7_4b.cc:30: error: expected ';' before '}' token
You should probably get rid off the useless comments first and properly indent and i'm sure well be able to help you then... Your code is all over the place and th comments make it even harder to read...
Please use Code Tags as well, It would be a little bit easier to read if you did.

If you're not sure what they are, ask us.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <iostream>

using namespace std;

int main()
{
//varible declaration
char letter;
int counter;

cout <<"\nStart to get character..."<<endl;
// Read the first character
cin.get(letter); // Notice get function for reading white spaces
counter = 0; // Initialize the counter
while( ) // Test if letter is end-of-line character
{
// check for non-white character: add operators to the following line
if((letter __ ' ') __ (letter __ '\t'))
________________________ //Increment counter
________________________ //Read the next character
}
cout <<"\nThe number of charater is "<< counter << endl;

cout <<"\nFinish running"<<endl;
return 0;

This is what i did, and i am new to this so please help me out here.

// Read the first character
cin.get(letter); // Notice get function for reading white spaces
counter = 0; // Initialize the counter
while(!letter.eof()) // Test if letter is end-of-line character
{
// check for non-white character: add operators to the following line
if((letter != ' ') __ (letter __ '\t'))
++counter; //Increment counter
______cin >> letter;__________________ //Read the next character
}

1170_7_4b.cc:24: error: request for member 'eof' in 'letter', which is of non-class type 'char'
1170_7_4b.cc:27: error: expected ')' before '__'
1170_7_4b.cc:29: error: '______cin' was not declared in this scope
1170_7_4b.cc:29: error: '__________________' was not declared in this scope
1170_7_4b.cc:30: error: expected ';' before '}' token 
Topic archived. No new replies allowed.