c - 如何在 Linux 上将文件读入 C 程序?

标签 c linux

使用 a.out file_name_here 运行已编译的 C 程序有什么区别?和a.out < file_name_here

我记得一些有关 Linux 管道的信息,但我不记得如何制作 a.out file 使用 < 接受文件符号。

基本上我要问的是:C 代码如何查找符合以下条件的 C 程序:

  1. file_name_here 是一个文本文件,内容为“hello world”
  2. 终端在命令行中获取“a.out < file_name_here”
  3. 终端显示输出:“hello world”

最佳答案

a.out file_name_here传递“file_name_here”作为参数。

a.out < file_name_here由 shell 处理,并将“file_name_here”的内容呈现给程序的“stdin”。

关于c - 如何在 Linux 上将文件读入 C 程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31375337/

相关文章:

java - 如何在 Java 中启动 shell 终端 session 并使用它来放置命令并读取其结果以保持先前的上下文

c - 当 .h 文件清楚可用时,为什么 autoconf 不通过 AC_CHECK_HEADER 测试?

c - 使用网站 www.codepad.org 您可以链接数学库吗?

linux - awk根据条件过滤文件

linux - 为什么 Plex Media Server 在 Ubuntu 16 上不适合我?

linux - Wayland 服务器何时会 ping 客户端?

c - 如何从我在 MASM 汇编器中调用的 C 函数调用 printf?

c - 使用scanf()时如何区分整数和字符

python - 重新排序数组中的值对,使它们按顺序排列

c - 管道没有得到 EOF