C 在执行期间手动将stdin重定向到文件
我需要能够在CLion中调试并重定向输入到stdin,但我找不到一种方法来做到这一点。我能想到的唯一解决方案是将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)
我考虑过使用freopen(),但这在C99中似乎无效,我必须将其用于我所在的类。不要在程序中读取
stdin
FILE *input = stdin;
if (debugging) input = fopen("somefile", "r");
// ... use `input`, not `stdin`
if (debugging) fclose(input);
虽然我不太明白你的意思,但请看一下,它可能会有帮助。我需要能够执行命令。/program.out