Allen
Allen

Reputation: 33

How can a command line program support piping arguments?

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!

Upvotes: 0

Views: 377

Answers (1)

Thomas Matthews
Thomas Matthews

Reputation: 57749

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.

Upvotes: 2

Related Questions