So lets say I had a string that was
<html>
<head><title>301 Moved Permanently</title><head>
and so
I’m using the str.find(); to find where the title tag starts and it gives me the correct position but how would I go about printing just the
301 Moved Permanently
My code:
string requestedPage = page.GetBody(); //Get the body of a page and store as string "requestedPage"
int subFromBeg = requestedPage.find("<title>"); //Search for the <title> tag
int subFromEnd = requestedPage.find("</title>"); //Search for the </title> tag
std::cout << requestedPage; //before
requestedPage.substr( subFromBeg, subFromEnd );
std::cout << requestedPage; //after
should be
std::string::substrdoesn’t modify the string, it returns a modified copy of the string.