printf affects following printf/s

Discussion in 'C Programming' started by azza, Oct 17, 2010.

  1. azza

    azza

    Joined:
    Oct 17, 2010
    Messages:
    1
    Hi,
    I spotted that when I use a typecasting in printf the next printf behaves according to that typecasting. I wonder why. Thanks. Here is a 2 example.
    If you comment out second printf the third printf's output changes accordingly.

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define RECT_AREA(x, y) (x)*(y)
    
    int main(int argc, char *argv[]){
        printf("%f\n", RECT_AREA(10, 5));
        printf("%f\n", RECT_AREA(10.0, 5));
        printf("%f\n", RECT_AREA(10, 5));
        return EXIT_SUCCESS;
    }
    
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    
    int main(int argc, char *argv[]){
        printf("%f\n", 10*5);
        printf("%f\n", 10.0*5);
        printf("%f\n", 10*5);
        return EXIT_SUCCESS;
    }
    
     
    azza, Oct 17, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Davide
    Replies:
    0
    Views:
    1,378
    Davide
    Oct 30, 2003
  2. =?Utf-8?B?anVubGlh?=
    Replies:
    2
    Views:
    577
    =?Utf-8?B?anVubGlh?=
    May 20, 2005
  3. milkyway

    Miminmize window affects the page

    milkyway, Sep 27, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    327
    David Ross
    Sep 27, 2005
  4. John Dalberg
    Replies:
    0
    Views:
    382
    John Dalberg
    Dec 20, 2005
  5. voxiac@gmail.com
    Replies:
    2
    Views:
    696
    John Machin
    Apr 22, 2007
Loading...

Share This Page