Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/docker/10.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 在执行期间手动将stdin重定向到文件_C_Clion - Fatal编程技术网

C 在执行期间手动将stdin重定向到文件

C 在执行期间手动将stdin重定向到文件,c,clion,C,Clion,我需要能够在CLion中调试并重定向输入到stdin,但我找不到一种方法来做到这一点。我能想到的唯一解决方案是将stdin设置为文件 我考虑过使用freopen(),但这在C99中似乎无效,我必须将其用于我所在的类。不要在程序中读取stdin FILE *input = stdin; if (debugging) input = fopen("somefile", "r"); // ... use `input`, not `stdin` if (debugging) fclose(input)

我需要能够在CLion中调试并重定向输入到stdin,但我找不到一种方法来做到这一点。我能想到的唯一解决方案是将stdin设置为文件


我考虑过使用freopen(),但这在C99中似乎无效,我必须将其用于我所在的类。

不要在程序中读取
stdin

FILE *input = stdin;
if (debugging) input = fopen("somefile", "r");
// ... use `input`, not `stdin`
if (debugging) fclose(input);

虽然我不太明白你的意思,但请看一下,它可能会有帮助。我需要能够执行命令。/program.out