piping output input
Essentially, I'm trying to pipe the output of a text file, lets call it test.txt, into my C program, lets call it program.
I assume I would evoke this by typing "cat test.txt | ./program".
In the actual code, I would handle it like any command line operation ( utilizing argc/argv ). Is this logic correct? I don't have to do any pipe programming do I?
Unfortunately my logic doesn't follow as it's not working. Any advice is appreciated.
here is the code i have written - its pretty simple.
int main( int argc, char * argv )
for(i=1; i < argc; i++)
You have to hope the shell you're running your program through doesn't parse your commands. You might type:
./foo < bar | baz
But for command line arguments, foo might not get anything.