home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / SMALL_C / OTOI.C < prev    next >
Text File  |  1987-10-04  |  384b  |  17 lines

  1. #include stdio.h
  2. /*
  3. ** otoi -- convert unsigned octal string to integer nbr
  4. **          returns field size, else ERR on error
  5. */
  6. otoi(octstr, nbr)  char *octstr;  int *nbr;  {
  7.   int d,t; d=0;
  8.   *nbr=0;
  9.   while((*octstr>='0')&(*octstr<='7')) {
  10.     t=*nbr;
  11.     t=(t<<3) + (*octstr++ - '0');
  12.     if ((t>=0)&(*nbr<0)) return ERR;
  13.     d++; *nbr=t;
  14.     }
  15.   return d;
  16.   }
  17.