小编Cri*_*ska的帖子

C++用<输入文件和>输出文件启动程序

我需要知道如何使用 Unix 参数 < 和 > 在 C++ 中工作,有人告诉我,如果我运行程序,./program < input file > output file程序将从后面声明的文件中读取,并在声明之后<写出到文件中>

实际代码看起来像这样

int main(int argc, char** argv) {

FILE* filein = fopen(argv[1], "r");
FILE* fileout = fopen(argv[2], "w");
Run Code Online (Sandbox Code Playgroud)

...

所以我想把我在程序开始时声明的文件放在这里处理,因为我将在程序中使用fileinfileout稍后。

我只被允许使用,stdio.h所以请保持基本。

提前致谢

c++ command-line file input output

1
推荐指数
1
解决办法
2514
查看次数

标签 统计

c++ ×1

command-line ×1

file ×1

input ×1

output ×1