How to send a simple string between two programs using pipes?

后端 未结 7 919
渐次进展
渐次进展 2020-11-22 12:17

I tried searching on the net, but there are hardly any resources. A small example would suffice.

EDIT I mean, two different C programs communicating with each other.

7条回答
  •  忘了有多久
    2020-11-22 12:18

    What one program writes to stdout can be read by another via stdin. So simply, using c, write prog1 to print something using printf() and prog2 to read something using scanf(). Then just run

    ./prog1 | ./prog2
    

提交回复
热议问题