Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. long decin (void) {
  2. int character; /* ASCII input from the user */
  3. long digit; /* each digit as it is found */
  4. long sum = 0; /* accumulated number */
  5.  
  6. /* input terminates with a non-digit character */
  7. while (isdigit (character = getchar())) {
  8.  
  9. /* change from ASCII */
  10. digit = character & ~ASCII_ZERO;
  11.  
  12. /* accumulate number */
  13. sum *= 10;
  14. sum += digit;
  15. }
  16.  
  17. /* return non-digit to input stream */
  18. ungetc (character, stdin);
  19.  
  20. /* result found */
  21. return sum;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement