1.新建控制台项目 test_debug

2.先准备一段代码 调试

#include <iostream>
//1.准备项目配置 输出..\..\bin (exe pdb) pdb是调试信息 和工作路径一致
//2.配置调试运行参数
void TestDebug() {
std::cout << "begin TestDebug" << std::endl;
std::cout << "end TestDebug" << std::endl;
}
int main(int argc,char *argv[])
{
TestDebug();
TestDebug();
std::cout << argv[1]<< "test debug\n"<<std::endl;
}
3.输出目录和工作目录要保持一致


4. F9在对应行代码设置断点
5.F5运行程序
6. F5是直接运行到下一个断点
7. F10 是单步调试 遇到函数不进入
8.F11是进入到函数内部
9.查看调试变量 定义好局部变量 全局变量 调试用
#include <iostream>
//1.准备项目配置 输出..\..\bin (exe pdb) pdb是调试信息 和工作路径一致
//2.配置调试运行参数
//3.F9设置断点
//4.开始调试
int g_count = 0;
void TestDebug(int x,int y) {
std::cout << "begin TestDebug x: " <<x<<" y: "<<y<< std::endl;
std::cout << "end TestDebug" << std::endl;
}
int main(int argc,char *argv[])
{
g_count++;
int cout = 0;
TestDebug(10,20);
TestDebug(10,20);
cout++;
std::cout << argv[1]<< " test debug\n"<<std::endl;
}