1. Background
Visual Studio 2019
entrance examination, I was learning C language and data structure, and I first used 061435c0321d50 as the editor, but I always felt uncomfortable;
I have been using Jetbrains's editor before, and I just found that C language can be used with CLion
, but I found that he would not use its debugging function. Sometimes in order to debug the code, it is necessary to copy the code into the Visual Studio 2019
editor; later I found it too troublesome. After groping for a while, I finally found the debugging method of CLion. Record the method to the students who need it.
2. Turn on debugging
Open CLion and create a new project; then select the following menu in the menufile
->settings
->Build、Execution、Deployment
->Debugger
->Data Views
->C/C++
Find Enable NatVis renderes for LLDB Diagnostics
select Verbose
, as shown in the figure below
After selecting, click the OK
button below to confirm.
Three, compile the code
Now you need to edit some code casually in the code. The variable assignment operation is required in the code to observe the debug mode. The reference code is as follows
#include <stdio.h>
int main() {
int i = 0;
while (i < 5) {
i++;
}
return 0;
}
After writing the code, mark the variables that need to be observed. The marking method is to click on the right side of the line number with the mouse, and a small red dot will appear, as shown in the figure below.
Next, you can use the debug mode to observe the variable data. There is a green bug icon at the top right of the editor. Click this icon to enter the debug mode.
Four, debug code
In debug mode, you can see the current value of the variable in memory, as shown in the figure below
When you need to let the program continue to execute, you need to click the red box in the middle, so that the program will execute to the next step, and you can see that the value of the variable is also changing. At the bottom you can see the variable list of the entire program, and the corresponding value how many.
- Author: Tang Qingsong
- Date: 2021-09-14
- WeChat: songboy8888
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。