[Courses] [C] yet one more question =)

Lorne Gutz lgutz at vistar.ca
Mon Nov 11 10:20:16 EST 2002

On Saturday 09 November 2002 00:00, Morgon Kanter wrote:
> What is up with this formatting? :
> printf("%6d", blah);

    this will make number like 34 for instance
use 4 spaces ^^^^34 before it for formatting. 
( think of the ^^^^ as 4 spaces)

>  - or -
> printf("%6.2d", blah);

       In this case you have 6 digits and two of them
are right of the decimal point.  eg   1.7 would be
written as  ^^^1.70.

> also, weird, you don't need to include stdio for printf to work. Theres
> also a nifty puts, putchar, and getchar.

         This is true, but when you use -Wall -Wstrict-prototypes 
-Wmissing-prototypes, you will get at least a warning if not an
error.   You should turn on as many warnings as possible,
because people make mistakes and this way the compiler
can find them for you.

> Morgon

More information about the Courses mailing list