string and parsing

Hi, I have a problem. If I have a string, for example "(3,4)" or "(8,9)", how can I understand that there are two numbers separated by a comma within two brackets?
I try with command "scanf" but nothing.
An example

1
2
3
4
5
6
int x, y;
char s[] = "( 3, 4 )";

std::sscanf( s, "( %d, %d )", &x, &y );

std::cout << "x = " << x << ", y = " << y << std::endl;
Last edited on
thanks very much!
and if I have a variable string and not char??
Boost.Xpressive would be great for this.
there is a little problem! if s="(8,9" (without close bracket), the script of vlad from moscow recognizes the two numbers, but I would recognize them only if there is also the final parenthesis. Any idea??!
Topic archived. No new replies allowed.