Command line argument is an important concept in C programming. It is mostly used when you need to control your program from outside. Command line arguments are passed to the main() method.
Syntax :
int main(int argc, char *argv[])
Example :
#include<stdio.h>
#include<conio.h>
int main(int argc,char *argv[])
{
printf("program name is %s\n",argv[0]);
printf("first argument %s\n",argv[1]);
printf("second argument %s\n",argv[2]);
printf("Third argument %s\n",argv[3]);
return 0;
}
#include<conio.h>
int main(int argc,char *argv[])
{
printf("program name is %s\n",argv[0]);
printf("first argument %s\n",argv[1]);
printf("second argument %s\n",argv[2]);
printf("Third argument %s\n",argv[3]);
return 0;
}
0 Comments