Command-line arguments in C

By: Jeffrey Emailed: 1586 times Printed: 2041 times    

Latest comments
By: rohit kumar - how this program is work
By: Kirti - Hi..thx for the hadoop in
By: Spijker - I have altered the code a
By: ali mohammed - why we use the java in ne
By: ali mohammed - why we use the java in ne
By: mizhelle - when I exported the data
By: raul - no output as well, i'm ge
By: Rajesh - thanx very much...
By: Suindu De - Suppose we are executing

This simple C program shows the method to accept and display command-line arguments.

#include <stdio.h>
int main(int argc, char *argv[])
{
   int x;
   // using for loop to iterate all the character...
   for(x = 1; x < argc; x++)
        printf("%s%s", argv[x],(x<argc-1) ? " ": "");
   // go to a new line...
   printf("\n");
   return 0;
}


C Home | All C Tutorials | Latest C Tutorials

Sponsored Links

If this tutorial doesn't answer your question, or you have a specific question, just ask an expert here. Post your question to get a direct answer.



Bookmark and Share

Comments(0)


Be the first one to add a comment

Your name (required):


Your email(required, will not be shown to the public):


Your sites URL (optional):


Your comments:



More Tutorials by Jeffrey
Command-line arguments in C
Simple arithmetic calculations in C
Find square and square root for a given number in C
Calculating total based on the given quantity and price in C++
The Object (compound) Type in PHP

More Tutorials in C
Sum of the elements of an array in C
Printing a simple histogram in C
Sorting an integer array in C
Find square and square root for a given number in C
Simple arithmetic calculations in C
Command-line arguments in C
Calculator in C
Passing double value to a function in C
Passing pointer to a function in C
Infix to Prefix And Postfix in C
while, do while and for loops in C
Unicode and UTF-8 in C
Formatting with printf in C
if, if...else and switch statements in C with samples
Statements in C

More Latest News
Most Viewed Articles (in C )
UNIX read and write system calls sample program in C
lseek() sample program in C
Using memset(), memcpy(), and memmove() in C
perror() Function - example program in C
Find square and square root for a given number in C
Open, Creat, Close, Unlink system calls sample program in C
Printing a simple histogram in C
scanf and sscanf sample program in C
Using free() Function in C
assert() Function Example program in C
Listing Files and Directories sample program in C
Sum of the elements of an array in C
goto and labels in C
Pointers to Structures example program in C
A C program similar to grep command in UNIX
Most Emailed Articles (in C)
Open, Creat, Close, Unlink system calls sample program in C
The C Character Set
Using malloc() Function in C
perror() Function - example program in C
Simple arithmetic calculations in C
Increment and Decrement Operators in C
register Variables in C
Listing Files and Directories sample program in C
Bitwise Logical Operators in C
Using qsort() and bsearch() with strings - example program in C
Formatting with printf in C
Printing a simple histogram in C
Relational and Logical Operators in C
While and For Loops in C
goto and labels in C