C Program to Print the Program Name and All its Arguments

This C Program Prints the Program Name and All its Arguments.
Here is source code of the C Program to Print the Program Name and All its Arguments. The C program is successfully compiled and run on a Linux system. The program output is also shown below.
  1. /*
  2.  * C Program to Print the Program Name and All its Arguments
  3.  */
  4. #include <stdio.h>
  5.  
  6. void main(int argc, char *argv[])    /* command line Arguments */
  7. {
  8.     int i;
  9.     for (i = 0;i < argc;i++)
  10.     {
  11.         printf("%s ", argv[i]);        /* Printing the string */
  12.     }
  13.     printf("\n");
  14. }

$ cc arg9.c
$ a.out this is  c class by myhackzs
a.out this is c class by myhackzs

0 comments:

Post a Comment

 
Top