CLion standard input while debugging

后端 未结 4 1208
[愿得一人]
[愿得一人] 2021-02-03 23:41

What I\'m trying to do is basically:

./myProgram < myData.txt

While I\'m debugging with CLion IDE. I just can\'t find the option to do so.

<
4条回答
  •  渐次进展
    2021-02-04 00:00

    Assuming your input file is myData.txt, you can reopen/reuse the stdin stream using freopen

    freopen("myData.txt","r",stdin);

    if you want to do the same with your output:

    freopen("myOutput.txt","w",stdout);

    this will work for std::cin, printf, etc...

    You can find more information about this here: http://www.cplusplus.com/reference/cstdio/freopen/


    By the way, there is already a feature request for this. If you are interested, you can vote here so it gets prioritized: https://youtrack.jetbrains.com/issue/CPP-3153

提交回复
热议问题