Receiving output from a pipe

Apr 10, 2013 at 2:05am
So I'm trying to make a program that will allow me to type in the command line something such as:

cat inputFile | myProg.exe otherFile1 otherFile2 ...

I know how to use argc and argv in myProg to use the arguments following it, but how do I access the output from the left of the pipe to use as my input for the right? I searched around and am clueless. Thanks in advance!
Last edited on Apr 10, 2013 at 2:06am
Apr 10, 2013 at 2:44am
IIRC the reason it is called a pipe is because the input file gets 'piped' into your program's standard input stream (std::cin).
Apr 10, 2013 at 3:20am
That helps, but I've run into another problem. How do I read the whole file into a buffer? I know I can use getline to read just one line, but how do I get all of it?

Edit: Nevermind I figure it out. Thanks!
Last edited on Apr 10, 2013 at 4:04am
Topic archived. No new replies allowed.