The only problem with that, is you have to store a pointer to it, in order
to free it. Mr. Barton there, posted probably one of the betters solutions
to it. It can be called any number of times. Markanth is good as well,
however alittle bit less memory effecient, but probably not much to be
concered (5 char var's 16 bytes large isn't too excessive, considering the
size of MSL)
Davion
From: "Valnir" <[EMAIL PROTECTED]>
Reply-To: "Valnir" <[EMAIL PROTECTED]>
To: "ROM List" <[email protected]>
Subject: Re: Re: Formatting numbers
Date: Thu, 12 Feb 2004 16:21:26 -0500
Sorry.. I missed that part.. I have done this type of thing before with
much
success, and without the static, but I usually am not tweaking someone
else's. Sorry.
Here is the final that I came up with that works fine (without a static):
char *fnum( long number )
{
int i, rest;
int n = 0;
char buf[MSL];
char buf_new[MSL];
buf[0] = '\0';
buf_new[0] = '\0';
sprintf( buf, "%ld", number );
rest = strlen(buf) % 3;
for ( i = 0; i < strlen(buf); i++ )
{
if ( i != 0 && ( (i - rest) % 3 ) == 0 )
buf_new[n++] = ',';
buf_new[n++] = buf[i];
}
buf_new[n] = '\0';
return str_dup(buf_new);
}
_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*
http://join.msn.com/?page=dept/bcomm&pgmarket=en-ca&RU=http%3a%2f%2fjoin.msn.com%2f%3fpage%3dmisc%2fspecialoffers%26pgmarket%3den-ca