Command Line Arguments in C.

#include<stdio.h>
#include<conio.h>
int main(int argc,char *argv[])
{
  int n;
  clrscr();
  printf("\n Enter elements:");
  for(n=0;  n<argc;  n++)
     {
         printf ("\n %s", argv[n]);
      }
  printf ("\n number of arguments in enterd is %d",argc);
  return 0;
}
 
In above program
1) argv[argc] is a null pointer.
2) argv[0]  holds the name of Program.
3) argv[1] horse the the first command line argument and argv[n] points last argument.

Post a Comment

0 Comments