i am trying to learn c++. i have a decent understanding of visual basic, and bought a book, c++ primer plus and am trying to complete the exercises, but in chapter 5 i ran into a problem with loops adding user input. it is supposed to take the user input and add each number the user inputs until a 0 is input. the code i have is as follows:
#include <iostream>
int main()
{
using namespace std;
int num;
int total = 0;
int x;
cout << "Enter number: ";
cin >> num;
while (num != 0) { total = total + num;
cout << total << endl;
cin >> "Enter a number "; //this is where the error is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream'
cin >> num;
}
cin.get();
return 0;
}
i have used the cin statement and i'm sure this is the way the signs are supposed to point, and i even did std::cin >> "Enter a number "; to see if that was it. any help is appreciated.




Reply With Quote