/*
* program accept argument from stdin as well as command line
* run it with
* echo "1 2 3" | ./a.out
* OR
* ./a.out 1 2 3
*/
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[])
{
int fromstdin = 0;
int i = 1;
char infile[200];
if (argc == 1) fromstdin = 1;
if (fromstdin)
{
memset(infile, 0, 200);
while (scanf("%s", infile) != EOF)
{
printf("stdin : %s\n", infile);
}
}
else
{
i = 1;
while (argv[i] != NULL)
{
printf("input : %s\n", argv[i]);
i++;
}
}
return 0;
}