How do I extract part of a string?
Let's say I have the string: "a, b, c, d, e, hi"
I saved it as a .txt file and then converted it to a .csv file. How would I write a code that will extract "d" and/or "hi" from this string?
This is the what I've come up with so far:
1 2 3 4 5 6 7 8
|
//let variable "inLine" contain the input line
string fourthLetter, sixthWord;
istringstream inStream;
inStream.str(inLine);
getline(inStream, fourthLetter, ',');
getline(inStream, sixthWord, ',');
|
I don't know if this is right. How do I specify which part of the string I want to extract?
Topic archived. No new replies allowed.