home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fish 'n' More 1
/
FishNMoreVol1.bin
/
more
/
code_examples
/
librar
/
jprintf.c
< prev
next >
Wrap
Text File
|
1989-02-08
|
872b
|
41 lines
/*--------------------------------------*/
/* */
/* JPRINTF(X) */
/* */
/* Prints a long integer in the format */
/* "%ld" with commas. */
/* */
/*--------------------------------------*/
# include "string.h"
# include "stdio.h"
void jprintf(i)
long i;
{
char r[40],rr[60],*z,zz[60];
int flag,j,x,y;
sprintf(r,"%ld",i);
x=strlen(r);
if (x<4){
printf(r);
exit(0);
}
flag=y=0;
for (j=x-1;j>=0;j--){
rr[y++]=r[j];
if (r[j]<47 || r[j]>57)
flag=1;
if (flag==0 && efactor(x-j,3)==0 && j!=0)
rr[y++]=',';
}
flag=x=rr[y]=0;
z=strrev(rr);
for (j=0;j<strlen(z);j++){
if (z[j]!=44 || flag!=0){
flag=1;
zz[x++]=z[j];
}
}
zz[x]=0;
printf(zz);
}