if(cin c) - error

Why i get this error for:
if(cin c){
cin c;
}

"if(cin c){}"->error: expected ')' before 'c'| and
"cin c"->error: expected ';' before 'c'|
Last edited on
Because you dont know how the cin operator works. What are you trying to do?

http://www.cplusplus.com/reference/istream/istream/operator%3E%3E/
Ooh thanks i forgot
firstly i would ask what is the purpose of your code, what are you trying to accomplish?
cin is an object of class ifstream, basically it accepts input from an external source such as your keyboard.

Here is an example:

1
2
3
4
5
6
7
8
9
10
#include<iostream> //header that includes stream objects eg cin and cout

int main()
{ string name;
   cout<<"What is your name?";//sends question to screen asking user for name 
   cin>>name;//allows the user to enter name and stores what was entered to 

return 0;

}



Last edited on
Topic archived. No new replies allowed.