Actient main

This is a discussion on Actient main within the C Programming forums, part of the General Programming Boards category; In a C book I own called Beggining with C by rob house, he writes main like this in a ...

  1. #1
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,475

    Actient main

    In a C book I own called Beggining with C by rob house, he writes main like this in a program:

    Code:
    #include stdio.h>
    
    main()
    {
    printf("I am the best, my number is %d", 7);
    
    return 0;
    }
    The book was published in 1995 and even though it is old all the programs work and he gives some sound tips on how to move onto C++ afterwards.

    Anyway, was main written like above standard back then? Even though it says that, I still use int main() {} in all my C programs. Why did he not use int main?

  2. #2
    ZuK
    ZuK is offline
    Registered User
    Join Date
    Aug 2005
    Location
    Austria
    Posts
    1,990
    There was a time when a functions returntype defaulted to int.
    Kurt

  3. #3
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    Quote Originally Posted by ZuK
    There was a time when a functions returntype defaulted to int.
    Kurt
    It still does, actually. Unless the return type explicitly specifies a return type, the compiler assumes it returns type int.
    If you understand what you're doing, you're not learning anything.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing params to main()
    By mike11 in forum C++ Programming
    Replies: 14
    Last Post: 06-21-2005, 12:36 PM
  2. pointers
    By InvariantLoop in forum C Programming
    Replies: 13
    Last Post: 02-04-2005, 08:32 AM
  3. Int Main or Void Main?
    By FromHolland in forum C++ Programming
    Replies: 9
    Last Post: 06-12-2003, 04:29 PM
  4. int main (), main (), main (void), int main (void) HELP!!!
    By SmokingMonkey in forum C++ Programming
    Replies: 7
    Last Post: 05-31-2003, 09:46 PM
  5. getting a function to return to main??
    By Neildadon in forum C++ Programming
    Replies: 7
    Last Post: 12-16-2002, 09:24 AM

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