I'm trying to do this assignment which involves searching for all instances of a tag in one text file and replacing all those tags with a word in another file. The text in the other file is currently:
I need to make a function that can skip past the beginning word and all the whitespace and then read and set "thought" to be equal to another string called "sub" (which I figure will use substr somehow). "thought" is just a simple example, I need it so that "sub" is equal to a single word length. EDIT: I checked and apparently it needs to work for multiple words. So instead if "thought" was "two words" I would need "sub" to be equal to "two words". Crap, that's even worse . "[What?]" is currently set as a string variable called "tag". "ss" is all the text from the replacement file. I was thinking I could subtract "tag" from "ss" and then set up a for-loop to skip past all the whitespace and start reading after that but I'm having a hell of a time getting my head wrapped around it. How would I get it to skip all the white space before and after the substitution string but still include the spaces between? How would I implement this?
Code:
void trim(string& ss) //
{
string sss = ss - tag;
size_t len = sss.length();
size_t lastPos, pos;
for (size_t i=0; i<len; ++i) //No clue how to start this
{
if (!isspace(sss[i]))
}
sub = sss.substr(a, b) /// How do I get a and b?
}