i am trying to learn c++ from a book, c++ primer plus, and visual studio 2010. i am stuck on an exercise in chapter 5 where i am suppposed to use a loop to take user input and keep a running sum until the user enters a 0. the code i have so far is:
#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
cin >> num;
}
cin.get();
return 0;
}
the full text of the error message is: error c2678:binary'>>':no operator found which takes a left-hand operand of type 'std::istream' . and one more thing i was wondering, is there a difference between c++ and visual c++? any help is appreciated.
Visual c++ is an IDE for programming in c++ (the language) so there is a difference but probably not the one you had in your mind when asking? There are also some things that MS support that are specific for them but those can be disabled if you want. Open the Project properties, select C/C++, Language and you find it. See here http://msdn.microsoft.com/query/dev1...SIONS)&rd=true
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
thanx for all the help. it's crazy how sometimes you can get so deep into it and miss the little stuff like this. and the reason i was asking about the differences was so that i could start writing apps for blackberry. i didn't want to be stuck with non portable code. i will disable the ms specific things so i don't run into that problem.
Bookmarks