Thread: Behavior of printf

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    8

    Behavior of printf

    Wanting to make sure the following leads to defined behavior (i.e. C standard). . .

    Code:
    double x1, x2, n;
    x1 = . . .
    x2 = . . .
    
    printf("%f %f %f %f", modf(x1, &n), n, modf(x2, &n), n);
    Are the arguments always evaluated left to right so that printf would report the intended value of n in each case?

    Thanks.

    Scott

  2. #2
    Registered User
    Join Date
    Dec 2001
    Posts
    88
    I don't have the Standard right here (it's at home)

    But function arguments are not evaluated in a defined order. And I don't see any reasons why it should be different with variadic functions.

    So my conclusion: sorry, it doesn't lead to defined behavior (it's implementation defined)
    Hope you don't mind my bad english, I'm Austrian!

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    8
    Thanks for the reply. It's good to know even if it's not the answer I'd hoped for.

    Scott

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. making it portable.....?
    By ShadeS_07 in forum C Programming
    Replies: 11
    Last Post: 12-24-2008, 09:38 AM
  2. get keyboard and mouse events
    By ratte in forum Linux Programming
    Replies: 10
    Last Post: 11-17-2007, 05:42 PM
  3. segmentation fault upon reload
    By yabud in forum C Programming
    Replies: 8
    Last Post: 12-18-2006, 06:54 AM
  4. Simple C question: user input to repeat a loop
    By evernaut in forum C Programming
    Replies: 2
    Last Post: 11-18-2006, 09:23 AM
  5. Drawing tables in C
    By stanoman in forum C Programming
    Replies: 5
    Last Post: 10-09-2003, 10:14 AM