Created
September 30, 2020 02:03
-
-
Save chelovekula/b81afd4e95f250782fa0efa642235f93 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// string::substr | |
#include <iostream> | |
#include <string> | |
int main () | |
{ | |
std::string str="--flag-switches-begin --timezone=\"America/New_York\" --flag-switches-end"; | |
std::size_t pos1 = str.find("--timezone=\"") + 12; | |
std::size_t pos2 = str.find("\" --flag-switches-end") - pos1; | |
std::string str2 = str.substr (pos1,pos2); | |
std::cout << str2 << '\n'; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment