STUDENTS 3K

  • Home
  • Students+
    • Engineering Students
    • Education Loan
    • Study Abroad Guide
    • Projects Download
  • Freshers
    • Aptitude Q & A
    • Placement Papers
    • Verbal Ability
    • Interview Questions
    • IT Company Details
    • Job Updates
  • Study Resources
    • Career Guidance
    • LAB Programs
      • C Programs
      • CPP Programs [C++]
      • Java Programs
    • Question Papers
    • Learn English
    • Notice Board
  • More –>>
    • Love calculator
You are here: Home / Important Programs / command line argument in C with example program

command line argument in C with example program

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.

  • Binary search in c using arrays with example program

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;
}

Filed Under: Important Programs Tagged With: C, LAB, Programs





Random Materials :

  • Data Mining and Data Warehousing
  • Difference Between Class and Primitive Types
  • Database Roles in SQL
  • CASE Expression in SQL
  • Concurrent Update Problem

Follow Us on Facebook

Advertisement

Company Profile

  • About Students3k
  • Contact Us
  • Earn Money Online
  • Website Archive Page
  • Privacy Policy
  • Disclaimer

Categories

  • Important Programs
  • Study Abroad
  • IT Companies
  • Career Guidance for Students
  • Teachers
  • Verbal Analogies

We Are Social

  • Facebook Fans
  • Twitter Follow
  • Google Plus
  • Pinterest Page

© Copyright 2012 - 2016 Students3k.com · All Rights Reserved · Designed By Benefits

Show