SSi*_*ilk 2 c++ ternary-operator command-line-arguments
我一直在使用OpenCV,我见过的一些示例代码使用以下内容来读取文件名.我知道argc是传递的命令行参数的数量,而argv是参数字符串的向量,但有人可以澄清下一行的每个部分的作用吗?我试过搜索这个,但没有找到很多结果.谢谢.
const char* imagename = argc > 1 ? argv[1] : "lena.jpg";
Run Code Online (Sandbox Code Playgroud)
谢谢.
const char* imagename = // assign the string to the variable 'image_name'
argc > 1 // if there is more than one cmd line argument (the first is always the program name)
? argv[1] // use the first argument after the program name
: "lena.jpg"; // otherwise use the default name of "lena.jpg"
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
568 次 |
| 最近记录: |