How to debug codeblocks? The following article will introduce it to you. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.
#CodeBlocks is an open source, full-featured cross-platform C/C integrated development environment (IDE).
Download address: http://www.codeblocks.org/downloads/26
Among them, you can use the installation package installation program in Windows environment, or use the installation-free zip.
Function of CodeBlocks Debugger
Generally speaking, the debugger is an indispensable tool in the IDE.
The debugger plays a very convenient role in tracking the code execution process and locating bugs.
Although it is said that you should not rely too much on the debugger, in general, especially when the program logic is complex, using a debugger can greatly improve the efficiency of program optimization and maintenance.
How to debug CodeBlocks?
The CodeBlocks debugger requires a complete project to start, and the debugger cannot be used on separate files. When using the debugger, it is best to create the project in an English path, and the path cannot contain Chinese characters.
1. Create a project
1) Create a project when or after CodeBlocks is started
2), select the console program
3), fill in the project name and path
4), select Compiler, the default is
5). After the project is created, as follows, you can write the program in the automatically created main.cpp, or create a new file
2. Start the debugger
1) Generally, the debugger button can be found on the toolbar
If not, you can call it from the view menu item
2), set breakpoints
Required when using the debugger Let the program interrupt at the required location. Set the breakpoint as follows before starting the debugger. Click the mouse on the left side of the editor to set the breakpoint.
3), start debugging
The debugger needs to be started in Debug mode, click the button debug:
After starting, when the program execution reaches the breakpoint, it will interrupt
If you encounter an input statement during execution, you need to complete the input before you can continue execution
In the toolbar Open the debugging window in, mainly open Watches
##Watches displays the value of the current variable, you can expand the array, In addition to the automatically displayed values, you can also manually add variables that need to be observed, such as a certain value in the array, Click Next line to execute the next statement, on the right Step into is to execute internal statements, and the red button Stop debugger on the far right is to end debugging; when executing a function call, you can use next line to directly execute the function, or step into to jump to the execution statement inside the function. If you want to stop debugging, click stop debugger, EndThe above is the basic method of using the debugger. The purpose of debugging is mainly to track variable values and observe whether the program behaves as expected. During execution, if a variable value is encountered that does not match expectations, the problem occurs in the previous statement.Before debugging, you need to consider the potentially problematic code segment and set a breakpoint after this code segment.
(In practical applications, you can try to use the VS debugger)
For more related knowledge, please pay attention to PHP Chinese website! !
The above is the detailed content of How to debug codeblocks?. For more information, please follow other related articles on the PHP Chinese website!