以下 bash 程序调用的作用是什么?
What does the following bash program call do?
我正在复习 material 无法理解以下内容:
我有一个编译好的 C myCProgram
程序,它以文本的形式打印出它的输入。所以如果它在 bash 中被调用
./myCProgram input.txt
和 input.txt
包含 "this is a test"
程序将在标准输出 "this is a test"
上输出。我有一系列潜在的 bash 程序调用来测试,我通过了除一个之外的所有程序,它是以下
./myCProgram file.txt < input.txt
它被描述为:您的程序将文件作为单个命令行参数,然后期望在 stdin 上输入。
任何人都可以向我解释这里发生了什么,并建议我应该如何在我的代码中处理它吗?
这会将 input.txt 的内容通过标准输入重定向到您的程序。这与以下内容相同:
./myCProgram file.txt
然后输入 input.txt
的内容
我正在复习 material 无法理解以下内容:
我有一个编译好的 C myCProgram
程序,它以文本的形式打印出它的输入。所以如果它在 bash 中被调用
./myCProgram input.txt
和 input.txt
包含 "this is a test"
程序将在标准输出 "this is a test"
上输出。我有一系列潜在的 bash 程序调用来测试,我通过了除一个之外的所有程序,它是以下
./myCProgram file.txt < input.txt
它被描述为:您的程序将文件作为单个命令行参数,然后期望在 stdin 上输入。
任何人都可以向我解释这里发生了什么,并建议我应该如何在我的代码中处理它吗?
这会将 input.txt 的内容通过标准输入重定向到您的程序。这与以下内容相同:
./myCProgram file.txt
然后输入 input.txt
的内容