Write your question here.
Can somebody help explain to me how to do string manipulation using substr() or find()? I feel like it is simple and I'm just over thinking it.
1 2
string substr, f, l;
string line = "F=John, L=Smith, V=3342";
int x = line.find("John"); //look for it, and save the index where it is if found.
string sub = line.substr(x,4); //we know its there, but if it were not you need to check x vs string::npos to see if it was found or not..
john is 4 long, so extract 4 chars to make the substring.
slightly more interesting, then..
x = line.find("V=");
if(x != string::npos)
cout << line.substr(x+2,4); //maybe we know V= but not the code number value
else
cout << "bad input" << endl;