I want to pass command line to my c program by reading another file using cat command as follows:
cat data | ./file
contents of the file data are
abc def ghi jkl mno pqr stu vwx yz
and code of the file.c is
#include <stdio.h>
int main( int args, char * argv[] )
{
int i = 0;
for( i; i < args; i++ )
{
printf(argv[i]);
printf("\n");
}
}
when the code is run as follows
cat a | ./file
it just display the file name and don't display the a contents. Am I doing it right?