Thread: Hello comunity!

  1. #1
    Registered User jfmarg's Avatar
    Join Date
    May 2012
    Location
    San Rafael, Mendoza, Argentina
    Posts
    3

    Hello comunity!

    Code:
    #include <stdio.h>
    
    main (){
    printf ("Hola\nMundo");
    }

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,739
    Use "int main(void)", "return 0;" at the end.
    Devoted my life to programming...

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Your printf argument should end with a \n, to flush the last word/line.

  4. #4
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    doesn't stdout automatically flush at the termination of the program?

  5. #5
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    2,158
    Quote Originally Posted by Elkvis View Post
    doesn't stdout automatically flush at the termination of the program?
    Yes, but relying on that feature isn't good practice.

  6. #6
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    is it just a common feature, or is it defined by some standard?

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by jfmarg
    Hello comunity!
    They usually call me "laserlight" rather than "comunity" around here, but... hi!

    Quote Originally Posted by Elkvis
    is it just a common feature, or is it defined by some standard?
    Well...
    Quote Originally Posted by C99 Clause 7.19.3 Paragraph 5 (part)
    If the main function returns to its original caller, or if the exit function is called, all open files are closed (hence all output streams are flushed) before program termination. Other paths to program termination, such as calling the abort function, need not close all files properly.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Tags for this Thread