Skip to content

Instantly share code, notes, and snippets.

@ericdke
Last active August 16, 2016 17:41
Show Gist options
  • Save ericdke/d8b55070a6b1355e92f3e74fb8dbe2ff to your computer and use it in GitHub Desktop.
Save ericdke/d8b55070a6b1355e92f3e74fb8dbe2ff to your computer and use it in GitHub Desktop.
C++: get int from console input
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int get_int()
{
string input;
int num;
getline(cin, input);
stringstream i(input);
i >> num;
return num;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment