so the user enters a string of coordinates like "(1,2) (3,4) (5,6) etc..." and I'm trying to use istringstream to pull out each number and put it into an integer value. This is what I've got so far:

string S1, temp;
int num1=0, tempX, tempY;

cout << S1 << endl;

istringstream ss(S1);
ss >> tempX;
cout << tempX << endl;

So far it only grabs the first number, and I'm at a loss of what to do next. Any suggestions?

Recommended Answers

All 2 Replies

You might want to consider to first break the problem into set of points (x,y). Then extract and convert each set of points to numbers.

Okay, so I extract each point into a vector of strings. Can someone show me how to copy a segment of a string into a separate string?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.