Thread: A question from a newbie regarding nested function

  1. #16
    Registered User
    Join Date
    Aug 2010
    Location
    Dhaka, Bangladesh
    Posts
    16
    Okey, Prototype seems clear to me in a way. But I'm wondering why we use "return 0" at the end of main(). What functions (activities) does it play in C programming?

    I've read about return value but couldn't grasp the intention of using return value.
    Last edited by Sharifhs; 08-09-2010 at 09:22 PM. Reason: added last line

  2. #17
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    It's used by the OS to indicate if the program was successful or not.


    Quzah.
    Hope is the first step on the road to disappointment.

  3. #18
    Registered User
    Join Date
    Aug 2010
    Location
    Dhaka, Bangladesh
    Posts
    16
    just to tell the operating system whether our program succeeded or not!!! Thanks quzah..

  4. #19
    Registered User
    Join Date
    Aug 2010
    Posts
    5
    Quote Originally Posted by Sharifhs View Post
    just to tell the operating system whether our program succeeded or not!!! Thanks quzah..
    More specificly the main function looks like this:

    Code:
    int main(void)
    Here you see the return type is int, integrer(a value without decimals). 0 is a integrer. In this case 0 means that the program ran without problems.

  5. #20
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    I honestly don't believe that the return value is defined. 0 may not necessarily mean success.
    That is, the return value is more for telling other programs of its operational status rather than the OS.
    Keep that in mind.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling C in Visual Studio 2005
    By emanresu in forum C Programming
    Replies: 3
    Last Post: 11-16-2009, 04:25 AM
  2. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  3. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  4. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  5. Newbie question about pointers in function parameters.
    By sojurn in forum C++ Programming
    Replies: 14
    Last Post: 01-20-2007, 09:21 PM

Tags for this Thread