Sponsored Links


Results 1 to 2 of 2

Thread: What is difference among main() int main() void main()

  1. #1
    Senior Member saneha's Avatar
    Join Date
    Apr 2011
    Posts
    266

    13 What is difference among main() int main() void main()

    Sponsored Links1



  2. #2
    Administrator Vuhelper's Avatar
    Join Date
    Apr 2011
    Posts
    9,578
    In C and C++, int main() is proper code, because main() always returns int according to the latest specifications for C and C++.

    int main() with no arguments is interpreted as int main(void). Earlier versions of the spec and pre-standard versions of C required explicit declaration [ie. int main(void)] but the current specs for both languages allow for implicit declaration. I believe even main() would be acceptable, though not formal enough for some people.

    void main (void) is not proper code, because main() always returns int. That's just how it's defined by the specification. Most compilers will accept it with just a warning, and interpret it as int main(void) before compiling. It's not likely to cause any problems as you can be fairly (but not 100%) confident that the compiler will fix it for you. You will find some books that use void main(void), but it's considered incorrect, or at least sloppy.

    main(int argc, char *argv[])

    argc is the number of argv. In one sense.
    argc is the number of arguments like -b,-ab . In other sense.

    argv is the argument . like -b , -ab ..., but first argv[0]=filename with full path

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 07-23-2014, 05:14 PM
  2. What are the main considerations
    By vustudents in forum Special and Local Law llb part 2
    Replies: 0
    Last Post: 09-08-2012, 11:57 PM
  3. Replies: 0
    Last Post: 08-24-2012, 10:48 PM
  4. Replies: 0
    Last Post: 05-01-2011, 12:35 AM
  5. Replies: 0
    Last Post: 12-14-2010, 03:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
-: Vuhelp Disclaimer :-
None of the files shown here are hosted or transmitted by this server. The links are provided solely by this site's users. The administrator's or staff of Vuhelp.net cannot be held responsible for what its users post, or any other actions of its users. You may not use this site to distribute or download any material when you do not have the legal rights to do so. It is your own responsibility to adhere to these terms. If you have any doubts about legality of content or you have any suspicions, feel free to contact us.
Online Education | JhelumSoft