Home > Common Problem > How to debug codeblocks?

How to debug codeblocks?

青灯夜游
Release: 2020-04-16 14:01:40
Original
8792 people have browsed it

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.

How to debug codeblocks?

#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

How to debug codeblocks? How to debug codeblocks?

2), select the console program

How to debug codeblocks?

3), fill in the project name and path

How to debug codeblocks?

4), select Compiler, the default is

How to debug codeblocks?

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

How to debug codeblocks?

2. Start the debugger

1) Generally, the debugger button can be found on the toolbar

How to debug codeblocks?

If not, you can call it from the view menu item

How to debug codeblocks?

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.

How to debug codeblocks?

3), start debugging

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

How to debug codeblocks?

After starting, when the program execution reaches the breakpoint, it will interrupt

How to debug codeblocks?

If you encounter an input statement during execution, you need to complete the input before you can continue execution

1How to debug codeblocks? 1How to debug codeblocks?

In the toolbar Open the debugging window in, mainly open Watches

1How to debug codeblocks?

##Watches displays the value of the current variable, you can expand the array,

1How to debug codeblocks?

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,

1How to debug codeblocks?

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,

How to debug codeblocks?

End

The 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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template