Command Line Argument in C
#include
int main(int argv,char *argc[])
{
clrscr();
printf("%s",argc[1]);
printf("\nNo. of arguments %d",argv);
return 0;
}
Here
argv - argument vector
argc - argument character
for execution
compile the above program now it will generate an EXE file
of that program
now in turboc
goto dos shell(File->Dos shell)
type the name of the program and some argument
Example: MyProgram Kunal
The output will be
Kunal
No. of arguments : 2
int main(int argv,char *argc[])
{
clrscr();
printf("%s",argc[1]);
printf("\nNo. of arguments %d",argv);
return 0;
}
Here
argv - argument vector
argc - argument character
for execution
compile the above program now it will generate an EXE file
of that program
now in turboc
goto dos shell(File->Dos shell)
type the name of the program and some argument
Example: MyProgram Kunal
The output will be
Kunal
No. of arguments : 2
Comments
Post a Comment