top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What happen internally in the system when return type of main () function make as void ?

+2 votes
402 views

If I correct , by default main () function has integer return type.
I want to know what happens in the system internally when its return type gets changed from integer to void ?

posted Jan 13, 2016 by Vikram Singh

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

we use int main() for C Programming but void main() works as well as int main() do. Operating systems pass the return value that sometimes called exit status to the calling program.Compilers will accept void main, but this is a non-standard extension (it usually means "always return zero to the OS" so explicitly void main return status 0 to operating systems same as after successful completion form any int main() function.

answer Jan 27, 2016 by Shivam Kumar Pandey
Hi Shivam, you answered very well. Could you please share some sort of references like online references/books/blogs etc ?
Similar Questions
+1 vote

We have two types of main declaration i.e.

void main()
and
int main()

I want to know the difference between these two and when to use what?

+1 vote

I am looking for internal details of following commands.
$ls * > 1.txt
I know this is very simple command used to re-direct the console output to a file.
But I want to know how does it work internally ? What the system does for this command ?

+2 votes

Many a times in C we get these two type of main function one had void as parameter one has none. Now the question is what is the difference between these two?

0 votes

There are two files.

    #include <stdio.h>
    void fun1(int i)
    {
            int a;
            printf("Enter the number\n");
            scanf("%d",&a);
            if(a==i)
                    printf("Equal\n");
            else
                    printf("Equal\n");
    }

    int main()
    {
        fun1(18);
    }

/* INPUT  */    
    18

What will be in file in OUTPUT file both cases.
Case-1:

./a.out < INPUT  > OUTPUT 

Case-2: Entered value is "18" from key board.

./a.out > output
...