Skip to content

Instantly share code, notes, and snippets.

@henix
Created September 16, 2013 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save henix/6577377 to your computer and use it in GitHub Desktop.
Save henix/6577377 to your computer and use it in GitHub Desktop.
with sign
int getint2(int *out) {
register int s = 0;
register int ch;
ch = getchar();
bool negative = false;
while (ch < '0' || ch > '9') {
if (ch == '-') {
negative = true;
ch = getchar();
break;
}
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
s = s * 10 + ch - '0';
ch = getchar();
}
*out = negative ? -s : s;
return ch;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment