Skip to content

Instantly share code, notes, and snippets.

@henix
Created September 11, 2013 07:43
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/6520434 to your computer and use it in GitHub Desktop.
Save henix/6520434 to your computer and use it in GitHub Desktop.
getint
int getint(char end) {
int s = 0;
int ch;
ch = getchar();
while (ch != end && ch != EOF) {
s = s * 10 + ch - '0';
ch = getchar();
}
return s;
}
int getint2(int *out) {
register int s = 0;
register int ch;
ch = getchar();
while (ch < '0' || ch > '9') {
ch = getchar();
}
while (ch >= '0' && ch <= '9') {
s = s * 10 + ch - '0';
ch = getchar();
}
*out = s;
return ch;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment