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
/
ITOD.C
< prev
next >
Wrap
Text File
|
2000-06-30
|
768b
|
31 lines
#include stdio.h
/*
** itod -- convert nbr to signed decimal string of width
** right adjusted, blank filled; returns str
**
** if sz > 0 terminate with null byte
** if sz = 0 find end of string
** if sz < 0 use last byte for data
*/
itod(nbr, str, sz) int nbr; char str[]; int sz; {
char sgn;
if(nbr<0) {nbr = -nbr; sgn='-';}
else sgn=' ';
if(sz>0) str[--sz]=NULL;
else if(sz<0) sz = -sz;
else while(str[sz]!=NULL) ++sz;
while(sz) {
str[--sz]=(nbr%10+'0');
if((nbr=nbr/10)==0) break;
}
if(sz) str[--sz]=sgn;
while(sz>0) str[--sz]=' ';
return str;
}
e feof() and ferror() to determine file status.
*/
read(fd, buf, n) int fd, n; char *buf; {
char *cnt; /*fake unsigned*