Thread: use a variable in format

  1. #1
    Registered User
    Join Date
    Sep 2001
    Posts
    173

    use a variable in format

    Hi

    how can I use a number in a format, such as

    n = 3;
    m = 123;

    and something like printf("%.nf", m);

    ---------
    result should be 123.000

    I tried with printf("%.%df\n",n,m); but never worked,any idea?
    Thanks
    Don't laugh at me,I am just a SuperNewbie.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Sep 2001
    Posts
    173
    thanks, I got it.
    Don't laugh at me,I am just a SuperNewbie.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to put a check on an extern variable set as flag
    By rebelsoul in forum C Programming
    Replies: 18
    Last Post: 05-25-2009, 03:13 AM
  2. C variable
    By webstarsandeep in forum C Programming
    Replies: 1
    Last Post: 10-23-2008, 01:26 AM
  3. Seeking Format Advice
    By PsychoBrat in forum Game Programming
    Replies: 3
    Last Post: 10-05-2005, 05:41 AM
  4. float/double variable storage and precision
    By cjschw in forum C++ Programming
    Replies: 4
    Last Post: 07-28-2003, 06:23 PM
  5. creating class, and linking files
    By JCK in forum C++ Programming
    Replies: 12
    Last Post: 12-08-2002, 02:45 PM