Do you expect exactly the (x,y) format (parenthesis, number, comma, number, parenthesis) or just x,y (number, comma, numer)?
Either way, you could read the non-digits as char:
1 2 3 4 5 6 7
|
char c1,c2,c3;
double x1,y1;
cin >> c1 >> x1 >> c2 >> y1 >> c3; // or cin >> x1 >> c1 >> y1;
if(! cin || c1 != '(' || c2 != ',' || c3 != ')')
{
// handle the input error
}
|
,
You could also modify the inputs stream to treat commas as space (takes a few lines of boilerplate code), or you could use a more serious parser like regex or boost.spirit.
Also, if you're looking for exactly (x,y) format, you could simply read the user input into a complex number. The complex numbers in C++ use exactly that syntax: parenthesis, number, comma, number, parenthesis.