Command Line Arguments

November 08, 2020

Command Line Arguments

  • argc (ARGument Count) is int and stores number of command-line arguments passed by the user including the name of the program.
  • argv(ARGument Vector) is array of character pointers listing all the arguments.
#include <stdio.h>
int main(int argc, char** argv)
{
  int i;
	printf("You have entered %d arguments\n",argc);
	for (i = 0; i < argc; ++i){
    		printf("%d",argv[i]);
  }
	return 0;
}

Written by Anushka Raj who likes to teach programming and work on front-end technologies. Follow me on Twitter and Instagram.