| 1 |
/*********************************************************************** |
| 2 |
* Code listing from "Advanced Linux Programming," by CodeSourcery LLC * |
| 3 |
* Copyright (C) 2001 by New Riders Publishing * |
| 4 |
* See COPYRIGHT for license information. * |
| 5 |
***********************************************************************/ |
| 6 |
|
| 7 |
#include <stdio.h> |
| 8 |
|
| 9 |
int main (int argc, char* argv[]) |
| 10 |
{ |
| 11 |
printf ("The name of this program is `%s'.\n", argv[0]); |
| 12 |
printf ("This program was invoked with %d arguments.\n", argc - 1); |
| 13 |
|
| 14 |
/* Were any command-line arguments specified? */ |
| 15 |
if (argc > 1) { |
| 16 |
/* Yes, print them. */ |
| 17 |
int i; |
| 18 |
printf ("The arguments are:\n"); |
| 19 |
for (i = 1; i < argc; ++i) |
| 20 |
printf (" %s\n", argv[i]); |
| 21 |
} |
| 22 |
|
| 23 |
return 0; |
| 24 |
} |