Created
September 11, 2013 07:43
-
-
Save henix/6520434 to your computer and use it in GitHub Desktop.
getint
This file contains hidden or 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
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