Reputation: 87
I am a novice C++ programmer, and I'm having some trouble with this program. I want to input points, Cartesian plane style, but this code is acting like it doesn't see the cin
any time but the first. A
is a class that holds the points. When run, the program I am able to input one pair, but when it gets to the while loop, it says Enter pair (0,0 to finish) Enter pair (0,0 to finish)...
repeatedly.
do {
cout << "Enter pair (0,0 to finish) ";
cin >> x >> y;
A.add( x, y );
} while ( !(x==0 && y==0) );
Any ideas?
Upvotes: 1
Views: 59
Reputation: 833
You should enter the two numbers with a space between them. The std::in
does not know how to handle other types of separators (besides white spaces).
Upvotes: 1