in Programming in C edited by
197 views
0 votes
0 votes

what is the use of void in main(void)?

my code is:

#include <stdio.h>
#include <conio.h>

int main(int argc,char *argv[]) 
{
    int i;
    if( argc >= 2 )
    {
        printf("The arguments supplied are:\n");
        for(i = 1; i < argc; i++)
        {
            printf("%s\t", argv[i]);
        }
    }
    else
    {
        printf("argument list is empty.\n");
    }
    return 0;
}

i run this code with and without the arguments in main() it works fine i.e., it is printing the arguments 

My doubt is even though i write void in the main(void) the above code is working fine,

i am confusing why it is working i am thinking that if i pass void in the main(void) the program should not take any value…..

anyone please tell me what is the reason and what is the use of void in the main(void)

in Programming in C edited by
by
197 views

Please log in or register to answer this question.