coding style

This is a discussion on coding style within the Linux Programming forums, part of the Platform Specific Boards category; Hey all been thinking about this a bit reciently. which of the following would run faster?? ------------------------------------------------ printf("Hello World"); ----------------------------------------------- ...

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

    coding style

    Hey all

    been thinking about this a bit reciently.
    which of the following would run faster??
    ------------------------------------------------
    printf("Hello World");
    -----------------------------------------------


    -----------------------------------------------
    char * string = "Hello World";
    printf("%s", string);
    -----------------------------------------------

    or
    -----------------------------------------------
    printf("%s","Hello World");
    -----------------------------------------------

    I dont particularly want to know for the printf function, but functions in general.. (printf is prob a bad example)

    I sometimes find it easier to read the code if it uses the 2nd style..
    I figure that once the code is compiled it wouldnt make a difference.

    Ive heard that the second style can make it easier for the compiler to compile code, which means the executable would be that little bit faster, Especially if your sending the return value from a function directly into that function:
    .. hmm not to good at explainging so heres an example

    ----------------------------------------------------------------------
    func2(func1());

    ----------------------------------------------------------------------

    does anyone have any input?

    cheers,
    ActionMan

    "THE DAY IS MYNE!!!!
    I'll take famouse titties for $400"
    -Sean Connery, Saturday Night Live

  2. #2
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,825
    Crossposting is bad for your health...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Is it bad style of coding ??
    By noobcpp in forum C++ Programming
    Replies: 15
    Last Post: 11-06-2008, 10:39 AM
  2. Your Coding Style?
    By Krak in forum A Brief History of Cprogramming.com
    Replies: 45
    Last Post: 06-02-2005, 09:19 AM
  3. Coding style?
    By Brian in forum A Brief History of Cprogramming.com
    Replies: 43
    Last Post: 10-22-2003, 12:26 PM
  4. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 10:44 AM
  5. Coding style
    By Clyde in forum A Brief History of Cprogramming.com
    Replies: 21
    Last Post: 04-09-2002, 05:22 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21