0

I have written a c++ command line program that successfully reads certain lines from a file, and then does something with the this data.

But, I want to use pipes in unix and windows to accomplish the same task. In order words:

cat file | ./myProgram

I have tried to google this, but I didn't find anything useful. Thanks in advance!

Allen
  • 33
  • 1
  • 6

1 Answers1

2

The operating system handles pipes. In the example you posted, the contents of file are sent to the standard input (cin) of myProgram.

So to be "pipe compatible" your program will need to read from cin to get its input.

Thomas Matthews
  • 56,849
  • 17
  • 98
  • 154
  • yes, and be careful when handling under windows system, a similar issue is here: http://stackoverflow.com/questions/36420233/ffmpeg-av-interleaved-write-frame-broken-pipe-under-windows – Allen Apr 24 '16 at 16:09