0

" For instance, the command below passes 1,000 pseudorandom numbers to find, which then searches those values for 42." ./generate 1000 | ./find 42

How come generate.c passes pseudo-random numbers to find.c? Where can I see this action(code)? How exactly does it work? How do they interact?

0

It's called "piping". That vertical bar between the two commands says "take the output from the program on the left and submit it directly (pipe it) to the program on the right as input." This is an operating system level operator, the vertical bar, that does the piping. It has nothing to do with the code in either generate.c or find.c.

You could run the command ./generate 1000 and it would send 1000 pseudo-random numbers directly to the screen. The OS level piping operator, | takes that output and sends it directly to ./find instead of displaying it. The piping operator can be used to pipe data between pretty much any two programs in a similar manner.

BTW, it isn't piping data between the .c programs. It's piping the data between the executables.

If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .