Skip to main content

'int main()' and 'void main()'

In C programming both the 'int main()' and 'void main()' are accepted.

'void main()' means that the main function doesn't return anything.

void main()
{
    // statements  
}

'int main()' says that the main function will return an integer to the operating system. For that we will return an integer to the operating system.

int main()
{
    // statements

    return 0; // since 0 is an integer
}

Some compilers are designed in such a way that they can't accept main function without returning anything, for those compilers we have to use 'int main()'.

Comments