Moving data from an array of strings to a struct

Nov 18, 2015 at 9:49pm
So I've got a struct that has the coordinates of a triangle like this:

struct Point {
double x;
double y;
};

struct Triangle {
Point a, b, c;
string color;
};

and an array of strings that has the coordinates/color in this format: {0,0,600,600,600,0,yellow) the first 6 numbers are coordinates in (x,y)format and the yellow part corresponds to the color of the color I intend on drawing.

My question is how do I take the data from the array and move it in the struct? I was hoping someone could point me in the right direction or provide some websites/examples of this being done, because I've no idea. Thanks in advance!
Nov 18, 2015 at 11:55pm
Use the string stream class (sstream). Then you can read data from the string just like you'd read it from cin.
Topic archived. No new replies allowed.