Topic_03 : Debugging practical


Debugging is a nice place to start understanding how computer programs work.  In fact, debugging is treated as an advanced concept for beginners and is not usually dealt in the academic institutions.

Bug actually means a mistake in our code.  Debugging is a process of removing bugs from our code.  Debugging involves a step by step execution of the statements in our code.

Unless, the programmer is well aware of the work behind the scene, the programmer can't understand the concepts clearly.  Now let's go to the explanation part on how the computer reacts while executing our program.

Consider our first program..
_______________________________________
# include <Stdio.h>

void main( )
{
    printf("Hello World");
}
_______________________________________

steps involved in starting step by step execution of this program..

1) After you type the program, press "F10" key to start debugging.  You'll be prompted if you want the IDE to build your application.  press "Yes" in that prompted box.
Dbg_01_MessageBox

2) If there are no errors in your program, an empty console window will appear on the screen.  And also, in the IDE, there appears a yellow arrow at the starting curly bracket after the main function.  That yellow arrow indicates that, the computer is going to execute the code in the line, pointed by that arrow.
Dbg_02_ConsoleWindow

3) Continue to press "F10", till the yellow arrow crosses the printf("Hello World"); line.  Now, press ALT+TAB to watch the console window.  You observe that, "Hello World" text is printed on the console window, which was empty earlier.
Dbg_03_ConsoleHelloWorld

4) Once, all the code in our program is completed, there won't be any more code left for the computer to execute.  IDE says the same message to you, once it reaches the end of the program.
Click on "OK" button.
Dbg_04_DebugEnd

5) Press "F5" key to let the debugging process to get terminated.

This is just starting to learn how to debug.  You'll come across more concepts, that are related to debugging in the later tutorials.  Once you have enough command on the programming language, you can learn more about debugging.