I am using xCode on a Mac to write some c++ code.
Any time I use cin >> the program compiles just fine, but when I run it something happens that I didn't expect. I enter what I want for input and hit the RETURN key, and it goes to the next line, waiting for me to type something else. As far as I know, it should stop looking for input at that point, but it doesn't. Here's an example:
#include <iostream>
using namespace std;
int main()
{
int Num = 0;
cout << "Enter a number: " << endl;
cin >> Num;
cout << "You entered: " << Num << endl;
return 0;
}
I never get to the "You entered: " statement, because I can't get it to assign the dang input! Anybody who knows what's going on, please let me know. Here's what the program looks like running:
Enter a number:
5
15
2546
x
b
5
No matter what I enter, when I hit the RETURN key, it just goes to the next line and waits. Thanks in advance for any help!
Danksalot