Can anyone tell me what wrong with JetBrains CLion, when I assign to Run/Debug Configurations - Program arguments something like "aaa bbb" and then print it:
printf("%s\n", argv[1]);
I just got "aaa", when it must be "aaa bbb" because they are in double quotes.
picture - this is what i get
Edit: tested in other IDEs (Dev C++, Codelite) and it works. Only Clion does not :( Just simple thing and can not figure it out...
From the main menu, select Run | Edit Configurations or choose Edit Configurations from the run/debug configurations selector on the toolbar. In the Run/Debug Configurations dialog that opens, select a configuration where you want to pass the arguments. Type the arguments in the Program arguments field.
To run CLion from the shell, use the open command with the following options: -a : specify the application. --args : specify additional arguments when passing more than just the file or directory to open. -n : open a new instance of the application even if one is already running.
In CLion, call Run | Attach to Process from the main menu or press Ctrl+Alt+F5 . After the debugger is attached successfully, you will be able to debug as usual. See the Debugging section for details. on the toolbar or in the Debug tool window to detach from the process.
For newer versions: Go to File --> Settings --> Build, Execution, Deployment --> CMake. Now click the "+" symbol, this should automatically add a Release profile (and, if you press "+" again, a Release with Debug Information profile).
This appears to be a bug in CLion. For me, it only happens when I start the application without debugging it (Run > Run 'Test'). When I start in debug mode (Run > Debug 'Test'), it works fine and displays the whole string.
I've created an issue with JetBrains. I'll update this answer as soon as I hear back from them.
Don't use Quotation marks("") and also make sure to delete any preceding spaces in Program argument text field in Run/Debug Configurations Windows, check the following screenshot.
image courtesy: uta
screenshot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With