answersLogoWhite

0


Best Answer

There is no default argument to the main function in C. Every C program must have one (and only one) main function. The standard dictates that the main function may have either of the following definitions:

int main (void) {/*...*/}

int main (int argc, char** argv) {/*...*/}

The first version is used when your program does not require any command-line switches. Note that int main () is an acceptable declaration of the main function in both C and C++, but is not a valid definition in C. Note also that, in C, the return type may be declared void, but not in C++.

The second version is more common. The argc argument holds the count of all arguments in the argv array and is always at least one. The argv argument refers to an array of char pointers to null-terminated character arrays thus all arguments are strings. Thus the value 42 will be passed as the string "42".

The first element, argv[0], is always the fully-qualified path to the program executable (hence argc is always at least one). As well as allowing your program to determine its physical location upon the system, it allows your program to determine its given name even if the user has renamed your executable. This is useful when printing error messages.

Any additional arguments passed from the command-line will be found in elements argv[1] through argv[argc-1]. The final element, argv[argc], is always nullptr.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

int main( void )

-its a default main function.

int main( int argc, char *argv[] )

-The variable argc never holds a negative value.

int main( int argc, char *argv[], char *envp[] )

-envp is pointer constant.it have string values.

  • argc is greater than zero.
  • argv[argc] is a null pointer.
  • argv[0] through to argv[argc-1] are pointers to strings whose meaning will be determined by the program.
This answer is:
User Avatar

User Avatar

Wiki User

15y ago

You will be surprised: it's main.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How is the main function called in a 'c' language program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the meaning of statement missing in function main in c language?

Every C program must have a function, named main(), which is where the program starts execution. If there is no function main(), the computer does not know where to start running the program. The function main() must also do something; if it is just empty, some smarter compilers will note that there is nothing for the program to do, and will give this sort of error message to indicate that you forgot to tell the program what to do.


What is a main function in c plus plus?

It is the first function that gets called when the program is executed.


Why the main function is called userdefine function in c language?

It's called 'main' by tradition; this feature lets the linker to know, where to start the execution.


What is the function of void main in c language?

Actually, it is:int main (void)orint main (int, char **)the point where the execution of the program begins


Where does c language program begin execution?

The execution of the program starts with function main, wherever it is in the source.


Write a Program in c language to find the LCM without using functions?

You're supposed to do your homework yourself. (Mind you, you have to hav at least one function called main.)


Why is function main special?

main() is so special because it starts the execution of program. or we can say that it is entry gate of any programming language


Where is the fuction call of main function?

The main function is the entry point into a program. When the Operating System launches the program the main function gets executed.


What is the main function of that organization?

to pump blood throughout the body and keep you alive.


What is the name of the function which must be defined in a Java program?

The main function. Every program must have a main function and it must be declared static.


What must every c program have?

A main function must be present in every C program.


Where do we write main function in a c program?

Into the source program.