Thursday, January 7, 2010

Printf storing Value in a variable

Try the following statement in  your program and see the interesting thing:
*******************************************************
printf("%*.*f%n",2,4,floatvar,&var);    //*.* 2.4digits & total No of Digits which was Printed stored at var.

Ex:
===

Value of variable float floatvar = 165.12345

2,4 specified in the printf format string will print the float as 165.1235
the variable var is :8(Including With spaces & dots & tabs & Newline)


The meaning is, var will store the number of characters printed...
[NOTE: See &var not var]


Advertise with my Blog

2 comments:

  1. salam sahabat
    storing value in variable its good posting make me know more ..ehm dah saya follow n follow baliknya dah belum thnx sn good luck ya

    ReplyDelete
  2. your info is nice!
    thanks for sharing

    ReplyDelete