clion-debug debugging steps

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;
}


测试一波
Insert picture description here

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.Insert picture description here

2. Click debug

Insert picture description here

3. Enter the data

Insert picture description here

4. Next instruction

Insert picture description here
At the same time, clion will put the corresponding value at the end of the line of code and
Insert picture description here
continue to the next instruction.
Insert picture description here
If there is a loop, click the arrow on the left border to go to the next instruction.
Insert picture description here
Clion's debug is very convenient for code debugging.

Published 22 original articles · praised 0 · visits 786

Guess you like

Origin blog.csdn.net/sjxgghg/article/details/105395864