How to debug CodeBlocks?

Lightweight concrete blocks 2021-09-03 13:47 110
How to debug CodeBlocks? The following article will introduce you. There is a certain reference value. Friends in need can refer to it. I hope it will be helpful to you

CodeBlocks is an open source full-featured cross platform C / C + + integrated development environment (IDE)

download address:

in Windows environment, you can use the installation package to install the program, or use the installation free zip

function of CodeBlocks debugger

generally, the debugger is an indispensable tool in the IDE


debugger plays a very convenient role in tracking the code execution process and locating bugs

although some people say that we can't rely too much on the debugger, in general, especially the program logic is complex, using the debugger can greatly improve the efficiency of program optimization and maintenance

how to debug CodeBlocks

the CodeBlocks debugger requires a complete project to start. A separate file cannot use the debugger. Using the debugger, it is better to create the project under the English path, which cannot contain Chinese characters

1, create a project

1), create a project when CodeBlocks starts or after startup

1.png 2.png

2), select the console program


3), fill in the project name and path

{0 4.png

4), select the compiler by default

{0 5.png

5). After the project is created, you can write the program in the automatically created main.cpp, Or create a new file


2, start debugger

1), in general, the debugger button can be found in the toolbar


, if not,


2 can be transferred from the View menu item, and set breakpoint

when the debugger is used, the program needs to be interrupted at the required location, and the breakpoint is set up before the debugger is set. Click on the left side of the editor to set the breakpoint,


3), start the debugger

the debugger needs to be started in debug mode, click the button debug:


after starting, when the program reaches the breakpoint, interrupt


if an input statement is encountered during execution, You can continue to execute

12.png 13.png

after the input is completed. Open the debugging window in the toolbar, mainly open watches


. The values of the current variables are displayed in watches. You can expand the array,


in addition to the automatically displayed values, you can also manually add variables to be observed, such as a value in the array,


click next line to execute the next statement, step into on the right is to execute the internal statement, and the red button stop debugger on the right is to end debugging; When a function call is executed, you can use next line to directly execute the function, or step into to jump to the internal execution statement of the function. If you want to stop debugging, click stop debugger,


. The above are the basic usage methods of the debugger. The purpose of debugging is mainly to track the variable value and observe whether the program is executing as expected, If the variable value is not as expected, the problem occurs in the previous statement

before debugging, you need to consider the code segment that may have problems, and set a breakpoint after this code segment

(in practical application, you can try to use vs debugger)

for more relevant knowledge, please pay attention to PHP Chinese website

above is how to debug CodeBlocks? For more details, please pay attention to other relevant articles on PHP Chinese network

Statement: This article was originally released on PHP Chinese website. Please indicate the source for reprint. Thank you for your respect! If you have any questions, please contact admin Recommended topics: CodeBlocks \t\t\t Previous article: how to add video to mobile WPS ppt \t\t\t Next: which should I choose between IPv4 and IPv6?