Last active
August 16, 2016 17:41
-
-
Save ericdke/d8b55070a6b1355e92f3e74fb8dbe2ff to your computer and use it in GitHub Desktop.
C++: get int from console input
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
#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