Article Directory
clion-debug debugging method
Artifact
(Let's start with a water question for everyone to understand)
题目要求:
Get two inputs a, b and find a + b.
输入数据
:
0001 0002
输出结果
:
3
附上代码
:
#include <iostream>
#include <cstring>
using namespace std;
int string_to_int(string str){
//避免字符串是全0
if(str.find_first_not_of('0') == string::npos)return 0;
str = str.substr(str.find_first_not_of('0'));
int a;
sscanf(str.c_str(),"%d",&a);
return a;
}
int main(){
string str1,str2;
cin>>str1>>str2;
int a = string_to_int(str1);
int b = string_to_int(str2);
int c = a+b;
cout<<c;
return 0;
}
测试一波
:
Operation details:
debug步
:
1. Breakpoint
A red dot will appear on the left side.
Because clion is more intelligent, the breakpoint is roughly within that range.
2. Click debug
3. Enter the data
4. Next instruction
At the same time, clion will put the corresponding value at the end of the line of code and
continue to the next instruction.
If there is a loop, click the arrow on the left border to go to the next instruction.
Clion's debug is very convenient for code debugging.