Why an error in while (cin >> #variablename#)?

0 votes
asked Mar 17 by (120 points)
Terminal gives me an error in

while (cin>>value) {.

It says there is no matching for ">> operand".

How to solve it?

1 Answer

0 votes
answered Mar 20 by (140 points)
You must be using %,& operator. In c++ you can directly use cin>>operand and variable name.

For e.g.

commented Mar 23 by (120 points)
I am using c++.
I defined a variable in main function, "value".
I defined a vector where the values the user types are gathered. Now, to have the user insert values I use a while cycle, like this:
while (cin>>value) {
Anyway, the debugger says there is an error in cin>>value operand... Can't understand why, the exaample you exposed is exactly the situation where I get told there is an error. :(
commented Mar 25 by (140 points)
Vectors in C++ are sequence containers representing arrays that can change in size.
for e.g.
  while(cin >> value[10])
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.