English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

4 answers

int main(int argc, char **argv, char **env);

2006-10-27 21:47:28 · answer #1 · answered by justinageneralway 3 · 0 0

The main function definition in C is

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

Suppose you have and exe file which is created using C program. Assume the name of the file is foo.exe. Now while you run this file you can pass arguments to the exe file like

foo 1 2 sridevi

In this case value of your argc will be 3, as there are 3 parameters passed. argv will store these parameters. so argv[1] = 1; argv[2] = 2; argv[3] = sridevi.

You can not pass these parameters in program. These must be passed at the run time.

2006-10-28 03:05:53 · answer #2 · answered by manoj Ransing 3 · 0 0

The main function can accept parameter from the command line as arguments.
To accept arguments, you should declare the main function as bellow
int main( int argc, char *argv[] )
In that, argc is the number of argument, include the program name itself, and argv contains values of arguments.
Example:
With the above declaration, the program name is prg1, and if you type in the command line:
> prg1 abc 333
argc will be 3
and argv[0] = prg1
argv[1] = abc
argv[2] = 333

2006-10-28 03:06:06 · answer #3 · answered by trung thanh 2 · 0 0

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

argc is number of arguments.

argv is array of pointers to "strings"

2006-10-28 03:03:54 · answer #4 · answered by Laughster 4 · 0 0

fedest.com, questions and answers