Pipe between C++ program and a cmd console

2019-07-01 10:38发布

I made a C++ program which spawns a command line and forwards commands to it. At the moment I'm sending the output of the cmd console to a file, and I'm reading it in my C++ program. But I want to make this work with pipes.

Is it possible to write to a named pipe from the Windows cmd line? I haven't found anything significant on this subject.

2条回答
等我变得足够好
2楼-- · 2019-07-01 11:06

Your terminology confuses me a bit - but I'm assuming that you are using VC (Visual C++)

I found this answer (to a similar question) that better explains how pipes and forks work (Well explained pipes examples)

查看更多
孤傲高冷的网名
3楼-- · 2019-07-01 11:14

You can use _popen for this, it's included in the C stdlib, so it should work on Windows.

http://pubs.opengroup.org/onlinepubs/009696699/functions/popen.html

You can pass the name of the second executable to the popen call in the first program.

查看更多
登录 后发表回答