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.
If someone is still interested in this, at the current date, CLion has added this feature. Go Edit Configurations (top right corner toolbar, name of your project | Debug):
Now there is an option: "Redirect input from". Just click the folder and find your input file.
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