CLion - command line program arguments

2019-06-16 20:32发布

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...

标签: cmake clion
2条回答
霸刀☆藐视天下
2楼-- · 2019-06-16 21:12

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.

查看更多
孤傲高冷的网名
3楼-- · 2019-06-16 21:19

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

查看更多
登录 后发表回答