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?

T94j0
  • 87
  • 10

1 Answers1

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

Ionel POP
  • 743
  • 7
  • 12
  • However, It is possible to [change the separator](http://stackoverflow.com/a/7304184/1925996). – piedar Mar 25 '16 at 21:28