home *** CD-ROM | disk | FTP | other *** search
/ vsiftp.vmssoftware.com / VSIPUBLIC@vsiftp.vmssoftware.com.tar / FREEWARE / FREEWARE40.ZIP / flistfrontend / src / scanint.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-22  |  787 b   |  38 lines

  1. #ifndef    NO_IDENT
  2. static    char    *Id = "$Id: scanint.c,v 1.4 1995/10/22 21:17:33 tom Exp $";
  3. #endif
  4.  
  5. /*
  6.  * Title:    scanint.c
  7.  * Author:    Thomas E. Dickey
  8.  * Created:    17 Jun 1985
  9.  * Last update:
  10.  *        19 Feb 1995, prototypes
  11.  *        04 Jul 1985, stepped on my good copy!!
  12.  *
  13.  * Function:    Translate an unsigned decimal integer, returning a pointer past
  14.  *        the decoded part.
  15.  *
  16.  * Arguments:    string    => string to decode
  17.  *        int_    = address of number to load, iff a number is found
  18.  *
  19.  * Returns:    Address of first character past the string of decimal digits.
  20.  */
  21.  
  22. #include    <ctype.h>
  23.  
  24. #include    "strutils.h"
  25.  
  26. char *
  27. scanint (char *string, int *int_)
  28. {
  29.     register int first = 1;
  30.  
  31.     while (isdigit(*string))
  32.     {
  33.         if (first)    first = *int_ = 0;
  34.         *int_    = (*int_ * 10) + (*string++ - '0');
  35.     }
  36.     return (string);
  37. }
  38.