Re: Formatting numbers

From: Al Bowers (xal_at_abowers.combase.com)
Date: 10/07/03


Date: Mon, 06 Oct 2003 22:41:50 -0400


Jack Klein wrote:
> On Tue, 07 Oct 2003 01:48:13 GMT, "Christopher Robin"
> <anonyngaddr@hotmail.com> wrote in comp.lang.c:
>
>
>>Hi,
>>
>>I'm trying to find if a function exists that would format a large (> 1000)
>>number with comma notation on a unix type system...
>>
>>I currently have
>>X = 10000;
>>
>>printf("X = %d\n", X);
>>which obviously only prints:
>>X = 10000
>>
>>I'd like it if I could find a function that would format it properly so it
>>would print:
>>
>>X = 10,000
>>

>
> Note that it doesn't really take a function, just a change in the call
> to printf:
>
> printf("X = %d,%d\n", X/1000, X%1000);
>

That would print: 10,0
ITYM printf("X = %d,%03d\n",X/1000, X%1000);

--
Al Bowers
Tampa, Fl USA
mailto: xal@abowers.combase.com (remove the x)
http://www.geocities.com/abowers822/


Relevant Pages

  • Re: Formatting numbers
    ... > number with comma notation on a unix type system... ... to printf: ... Jack Klein ...
    (comp.lang.c)
  • Formatting numbers
    ... I'm trying to find if a function exists that would format a large ... number with comma notation on a unix type system... ... I'd rather not design/write it myself if it already exists. ...
    (comp.lang.c)
  • Re: variable length record using struct/union - help
    ... >> I want to access a variable length record in C, the format is as ... No, don't, it's undefined behavior. ... Jack Klein ... FAQs for ...
    (comp.lang.c)