home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / ENTERPRS / CPM / UTILS / S / SMC21LIB.LZH / ITOO.C < prev    next >
Text File  |  2000-06-30  |  640b  |  30 lines

  1.  
  2. #include stdio.h
  3. /*
  4. ** itoo -- convert nbr to octal string of length sz
  5. **         right adjusted, blank filled; returns str
  6. **
  7. **        if sz > 0 terminate with null byte
  8. **        if sz = 0 find end of string
  9. **        if sz < 0 use last byte for data
  10. */
  11. itoo(nbr, str, sz) int nbr; char str[]; int sz; {
  12.   int digit;
  13.   if(sz>0) str[--sz]=0;
  14.   else if(sz<0) sz = -sz;
  15.   else while(str[sz]!=0) ++sz;
  16.   while(sz) {
  17.     digit=nbr&7; nbr=(nbr>>3)&8191;
  18.     str[--sz]=digit+48;
  19.     if(nbr==0) break;
  20.     }
  21.   while(sz) str[--sz]=' ';
  22.   return str;
  23.   }
  24.  
  25.  
  26. -sz]=sgn;
  27.   while(sz>0) str[--sz]=' ';
  28.   return str;
  29.   }
  30.