【问题标题】:Redirect stdin to pipe (popen) C++将标准输入重定向到管道(popen)C++
【发布时间】:2012-03-07 09:21:31
【问题描述】:

我希望这不是一个愚蠢的问题。是否可以将标准输入重定向到文件?

FILE* somePipe = _popen("SOME_FILE", "r");

我可以将 somePipe 分配给标准输入吗?

【问题讨论】:

标签: c++ pipe stdin


【解决方案1】:

尝试使用freopen()

 FILE* somePipe = freopen("SOME_FILE", "r", stdin);

【讨论】:

    【解决方案2】:
     FILE* inPipe   freopen("newstdin", "r", stdin);
     FILE* outPipe  freopen("newstdout", "w", stdout);
    

    【讨论】:

      猜你喜欢
      • 2016-04-26
      • 1970-01-01
      • 2018-12-13
      • 2012-05-28
      • 2020-02-06
      • 1970-01-01
      • 2013-02-10
      • 2013-07-16
      • 1970-01-01
      相关资源
      最近更新 更多