Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在C语言中读取命令行参数_C_Command Line_Cmd_Arguments - Fatal编程技术网

在C语言中读取命令行参数

在C语言中读取命令行参数,c,command-line,cmd,arguments,C,Command Line,Cmd,Arguments,我希望通过以下方式将文件作为参数传递: a.exe < testfile 我编译这个,当我像这样在CL中运行它时 a.exe < testfile 为什么呢?我在建议的解决方案中读到了关于stdin的内容,但现在我被困在这里。重定向

我希望通过以下方式将文件作为参数传递:

a.exe < testfile
我编译这个,当我像这样在CL中运行它时

a.exe < testfile

为什么呢?我在建议的解决方案中读到了关于stdin的内容,但现在我被困在这里。

重定向
将用文件
testfile
替换标准输入流


只需像使用stdin从键盘读取数据一样读取输入。

您可以将其作为stdin获取,因为这是shell重定向(以及可执行文件中的libc初始化)之后的结果。

这不是命令行参数,而是通过管道传输到stdin。你想做什么,展示你的代码,说明你的问题具体在哪里。
a.exe < testfile
`