mdelatorre

argc and argv[] example in C

Feb 22nd, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.36 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main (int argc, char *argv[])
  4. {
  5.   int count;
  6.  
  7.   printf ("This program was called with \"%s\".\n",argv[0]);
  8.  
  9.   if (argc > 1)
  10.     {
  11.       for (count = 1; count < argc; count++)
  12.     {
  13.       printf("argv[%d] = %s\n", count, argv[count]);
  14.     }
  15.     }
  16.   else
  17.     {
  18.       printf("The command had no other arguments.\n");
  19.     }
  20.  
  21.   return 0;
  22. }
Add Comment
Please, Sign In to add comment