Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <vector>
- // Method to parse a string using the `delim` character
- std::vector<std::string> parse(std::string input, char delim) {
- std::vector<std::string> tokens;
- std::stringstream stream(input);
- std::string token;
- while(getline(stream, token, delim)) {
- tokens.push_back(token);
- }
- std::string lastToken = tokens[tokens.size() - 1];
- //tokens[tokens.size() - 1] = lastToken.substr(0, lastToken.length() - 1);
- return tokens;
- }
- // Convert an integer represented as a string into an int
- int stringToInt(std::string str) {
- int ans = 0;
- for (int i = 0; i < str.length(); i++) {
- ans = ans * 10 + (str[i] - '0');
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement