C++第四十七篇 -- VS2017带参数启动调试程序


参考链接:https://www.cnblogs.com/kileyi/p/10163269.html

举例:Test_Bluetooth.exe -help

Test_Bluetooth.cpp

#include "pch.h"
#include <iostream>
using namespace std;

void help() {
    cout << "help" << endl;
}

int main(int argc, char* argv[])
{
    if (argc == 2) {
        if (strcmp(argv[1], "-help") == 0) {
            help();
        }
    }
    else {
        cout << "Hello World!\n";
    }
}
View Code

工具是TestBluetooth.exe,参数是-help,功能是在控制台打印help。

默认执行程序不带任何参数,会在控制台打印Hello World!。若想带上参数-help,需要在工程属性中设置。

右击项目名称 --》属性 --》 Debugging --》Command Arguments里面填入-help。

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM