fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. using namespace std;
  5.  
  6.  
  7. vector<string> foo(const string& url)
  8. {
  9. vector<string> result;
  10. auto a = url.find("?");
  11. if (a == string::npos) return result;
  12.  
  13. auto b = url.find("&");
  14. if (b == string::npos)
  15. {
  16. result.push_back(url.substr(a + 1, string::npos));
  17. return result;
  18. }
  19. result.push_back(url.substr(a + 1, b - a - 1));
  20. do
  21. {
  22. a = b;
  23. b = url.find("&", a + 1);
  24. result.push_back(url.substr(a + 1, b - a - 1));
  25. } while (b != string::npos);
  26.  
  27. return result;
  28. }
  29.  
  30. int main()
  31. {
  32. std::string url = "https://www.google.com/search?q=i+need+help&rlz=1C1CHBF_enUS851US851&oq=i+need+help&aqs=chrome.0.69i59j0l3j69i60l2.4646j0j7&sourceid=chrome&ie=UTF-8";
  33. auto vec = foo(url);
  34. for (const auto & i : vec)
  35. cout << i << endl;
  36. }
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
q=i+need+help
rlz=1C1CHBF_enUS851US851
oq=i+need+help
aqs=chrome.0.69i59j0l3j69i60l2.4646j0j7
sourceid=chrome
ie=UTF-8