Skip to content

Instantly share code, notes, and snippets.

@benblack769
Created September 17, 2016 00:16
Show Gist options
  • Save benblack769/d9bd24586e5474bc7afe23d4e191a631 to your computer and use it in GitHub Desktop.
Save benblack769/d9bd24586e5474bc7afe23d4e191a631 to your computer and use it in GitHub Desktop.
#include <iostream>
#include <sstream>
using namespace std;
string next_line(){
//breaks if there is no line to get
string line;
getline(cin,line);
return line;
}
vector<string> get_lines_until_end(){
vector<string> strs;
string line;
while(getline(cin,line)){
strs.push_back(line);
}
return strs;
}
vector<string> split(string line){
stringstream ss(line); // Insert the string into a stream
vector<string> tokens; // Create vector to hold our words
string buf;
while (ss >> buf){
tokens.push_back(buf);
}
return tokens;
}
//also remember the standard library functions
//stoi (string to int)
//stod (string to double)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment