I want to read .txt file in my C/C++ project in CLion IDE.
I want to automate the command that I run in bash:
./<executable_file> < input.txt
I edited program parameter in Run/Debug configuration.
But it does not works.
I want to read .txt file in my C/C++ project in CLion IDE.
I want to automate the command that I run in bash:
./<executable_file> < input.txt
I edited program parameter in Run/Debug configuration.
But it does not works.
It is not officially supported as of now, you can do the following.
If your input file is input.txt, you can use freopen to set stdin file as input.txt
freopen("input.txt","r",stdin);
if you want to do the same with your output:
freopen("output.txt","w",stdout);
this will work for std::cin (if using c++), printf, etc...
This will help you in debugging your code in clion
Similar Question CLion standard input while debugging
Not a direct solution but the alternative you can do using your command line.
g++ -Wall -ggdb filename.cpp -o filename
and run it using:
./filename < inputFile
Also, I don't think JetBrain has an official answer to this type of issue for Clion yet...
© 2022 - 2024 — McMap. All rights reserved.