1

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?

0

1 Answer 1

1

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).

Sign up to request clarification or add additional context in comments.

1 Comment

However, It is possible to change the separator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.