The original "Hello World" program can be modified slightly to demonstrate argument passing
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc == 3) {
printf("Hello, %s and %s!\n", argv[1], argv[2]);
return 2;
}else if (argc == 2) {
printf("Hello, %s!\n", argv[1]);
return 1;
}else{
printf("Hello, world!\n");
return 0;
}
}
If you name the program `hello' then type commands like
hello
hello bob
hello bob sue
The return value tells you how many names your program read (0, 1, or 2).