Easy learning with example program codes

C Command Line Arguments

Command line arguments are passed inside the main function of a C program also called as command line of the C program, hence the name, command line arguments.


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

  • Argc: This is a mandatory parameter that counts the number of arguments.
  • Argv[]: This is also a mandatory parameter that contains all the arguments.


#include <stdio.h>  
void main(int argc, char *argv[] )  
printf("File name: %s\n", argv[0]);  
if(argc < 2)
      printf("No argument passed.\n");  
      printf("Argument 1: %s\n", argv[1]);  


File name: C_program
Argument 1: welcome
Posted in C   

Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at


We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on

Copyright © 2019 CodesJava Protection Status SiteMap Reference: Java Wiki