06/12/16 23:59:43
int comma_format(long value, char *buf)
{
char temp[20];
int i, temp_len;
if(value<0) *buf++='-';
sprintf(temp, "%ld", labs(value));
temp_len=strlen(temp);
for(i=0;i<temp_len;i++)
{
*buf++=temp[i];
if((temp_len-i)%3==1)
*buf++=',';
}
buf[-1]='\0';
return 1;
}