分类: LINUX
2009-09-07 16:34:02
/*
* main.c
*/
#include <stdio.h>
#include <unistd.h>
int
main(int argc, char *argv[])
{
int r;
r = execlp("./hello",
"What's your name?",
"What did you say?",
"What is your name?",
"Oh, call me World.",
(char *)0);
return 0;
}
/*
* hello.c
*/
#include <stdio.h>
int
main(int argc, char *argv[])
{
int i;
for (i = 0; i < argc; i++) {
printf("%s\n", argv[i]);
}
return 0;
}
/*
* The out put is as the following:
*================================
$ make main hello && ./main
cc -g main.c -o main
cc -g hello.c -o hello
What's your name?
What did you say?
What is your name?
Oh, call me World.
$
*================================
*/