I want to take the user's input which will be in this format-- (xx, xx, x) where the x is some arbitrary double value and there is always a comma and whitespace after every value.
I've taken this input as a string value to parse it and check if the user didn't put anything funky. I'm having trouble turning the string into a double and then adding those values into a vector of double type. I tried using the atof function, but I am confused as to how i can add to the vector after the first element.
This is what I have so far in C++..
string vector1, vector2;
//asks for first vector
cout << "Enter first vector"<<endl;
getline(cin,vector1);
vector <double> Vector1;
//vector1 without the parantheses
vector1= vector1.substr(1,vector1.length()-2);
cout<< vector1<<endl;
Vector1.push_back(atof(vector1.c_str()));
cout<< Vector1[0];
Any ideas? I was thinking of making a loop but I don't how to tell the atof function to continue after the comma and whitespace.