home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d1xx
/
d186
/
cards'o'rama.lha
/
Cards'O'Rama
/
Sources
/
sources.zoo
/
intascii.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-25
|
1KB
|
43 lines
/* intascii.c */
/* */
/* Very trivial but useful: converts an unsigned integer into an ASCII */
/* string of the given lenght that can be used by the Text() function */
char *intascii(number, string, lenght)
unsigned int number;
char string[];
int lenght;
{
int i, c, j;
char *oldstring = "000000";
int difference;
i = 0;
do
string[i++] = number % 10 + '0';
while((number /= 10)> 0);
string[i] = '\0';
for(i = 0, j = strlen(string) -1; i < j; i++, j--)
{
c = string[i];
string[i] = string[j];
string[j] = c;
}
if(strlen(string) < lenght)
{
difference = lenght - strlen(string);
for (i = 0; i < difference; i++)
oldstring[i] = '0';
j = 0;
while((oldstring[i++] = string[j++]) != '\0')
;
}
else
oldstring = string;
return(oldstring);
}