Programming Tutorials

Command-line arguments in C

By: Jeffrey in C Tutorials on 2012-03-16  

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





Add Comment

* Required information
1000

Comments

No comments yet. Be the first!

Most Viewed Articles (in C )

Latest Articles (in C)