code.cpp 472 B

1234567891011
  1. /* Create a function to extract the name of the subreddit from its URL.
  2. */
  3. std::string subReddit(std::string link) {
  4. // find the beginning of the subreddit "/r/"
  5. std::size_t subStart = link.find("/r/")+3;
  6. // save everything after "/r/"
  7. std::string subredditandJunk = link.substr(subStart);
  8. // save the text from the "/r/" to the next "/"
  9. return subredditandJunk.substr(0,subredditandJunk.find("/"));
  10. // return link.substr(subStart, link.size()-size_t(30));
  11. }