Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long decin (void) {
- int character; /* ASCII input from the user */
- long digit; /* each digit as it is found */
- long sum = 0; /* accumulated number */
- /* input terminates with a non-digit character */
- while (isdigit (character = getchar())) {
- /* change from ASCII */
- digit = character & ~ASCII_ZERO;
- /* accumulate number */
- sum *= 10;
- sum += digit;
- }
- /* return non-digit to input stream */
- ungetc (character, stdin);
- /* result found */
- return sum;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement