home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung 2 / Power-Programmierung CD 2 (Tewi)(1994).iso / c / library / dos / convert / c_conver / itod.c < prev    next >
Encoding:
C/C++ Source or Header  |  1984-11-19  |  768 b   |  31 lines

  1. /*----- ARCHIVE itod.c -----------------------------------------------------*/
  2. /*
  3. **    itod -- convert nbr to signed decimal string of width sz
  4. **        right adjused, blank filled; return str
  5. **
  6. **        if sz > 0 terminate with null byte
  7. **        if sz = 0 find end of string
  8. **        if sz < 0 use last byte for data
  9. */
  10. #define NULL    0
  11. itod(nbr,str,sz) int nbr; char str[]; int sz; {
  12.     char sgn;
  13.     if (nbr<0) {nbr=-nbr; sgn='-';}
  14.     else sgn=' ';
  15.     if (sz>0) str[--sz]=NULL;
  16.     else if (sz<0) sz=-sz;
  17.     else while (str[sz]!=NULL) ++sz;
  18.     while (sz) {
  19.         str[--sz]=(nbr%10+'0');
  20.         if ((nbr=nbr/10)==0) break;
  21.     }
  22.     if (sz) str[--sz]=sgn;
  23.     while(sz>0) str[--sz]=' ';
  24.     return str;
  25. }
  26. to directory buffer
  27.     ;
  28. DIRBUF:    DS    ENTRIES*16    ;directory buffer
  29.     ;
  30.     END    BEGIN
  31. PA:X