I have the following code but it only converts strings to double. if the string contains a letter, it causes an error
while (cin >> s){
const char *c_ptr=s.c_str();
d = atof(c_ptr);
v.push_back(d);
}
I want to input a string like “a1.2 3 4b” and have the vector populated with “1.2 3 4”
What about this:
since you got rid of the letters before parsing the doubles, they should no longer cause issues.