command line argument in C: An example C program is available here. Given source code is based on command line operations by passing arguments with the advantage of arrays. Sample code is also given below for your reference.
COMMAND LINE ARGUMENT IN C
This C program is used to pass the arguments as the command statement. Declare the variables and pass the value by using a command format of statement.
[Read: IT Company List] & [Placement papers download]
Command line argument program:
Q: Write a C program for binary command line arguments with an example program.
/*
Author: Vinoth Selvaraj
© http://students3k.com
*/
//Header files
#include<stdio.h>
#include<conio.h>
//Global variables
int main(int ar, char *ar[])
{
int ct; //Program variables
clrscr(); //Function to clear previous output
printf("Program name: %s\n", ar[0]); //Display function
if(ar>1) //Conditional statement
{
for(ct=1; ct<ar; ct++) //Looping statement
printf("Argument %d: %s\n",ct,ar[ct]);
}
else
puts("No command line argu entered.");
getch();
return 0;
}