Command-line arguments in C

By: Jeffrey  

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




Archived Comments


Most Viewed Articles (in C )

Latest Articles (in C)

Comment on this tutorial