suh*_*has 3 c unix shell redirect command-line
我在C编码并在Linux终端中运行程序.我想将程序的输出保存在.txt文件中.我通常通过执行来做到这一点./a.out>filename.txt
但是我写了一个交互式程序,我必须在其中输入一个数字来启动该程序.在那种情况下我该怎么做?
非常感谢,非常欢迎您的宝贵建议.
移动需求以从终端输入一个数字到命令行参数.
./a.out 42 > filename.txt
或者,更容易,接受来自重定向输入的输入
echo 42 | ./a.out > filename.txt ./a.out < input.txt > filename.txt