char *commafy(unsigned long long val)
{
char *buf1, *buf2;
int len, i, p2;

buf1=malloc(40);
memset(buf1, 0, 40);
buf2=malloc(40);
memset(buf2, 0, 40);
sprintf(buf1, "%Ld", val);
len=strlen(buf1);
p2=0;

for(i=len; i>=0; i--){
        *(buf2+(40-p2)) = *(buf1+i);
        p2++;
        if( (i) && (len-i) && (((len-i)/3) == ((float)(len-i)/3)) ) {
                *(buf2+(40-p2)) = ',';
                p2++;
                }
        }

return(buf2+(41-p2));
}
