Wednesday 8 January 2014

How to Debug a program in C language(Run every line of code )

     

Debugging is most important method while you are dealing with C language. Use of breakpoint,single line execution button is also has its own importance. If you want to be a good developer of C programming you should know how to use debug button in a program.

Here Definition of Debugging. I copied this from one of websites.

"Debugging tools (called debuggers) help identify coding errors at various development stages. Some programming language packages include a facility for checking the code for errors as it is being written."


But main thing is that how to use debug method in a program and how to use watch button in Integrated development environment(Dev C++). Here i am going to introduce debug method with Dev c++ firmware snaps.


1-When you compiled your program and remove all errors then do not click on  run but instead go with debug option. You can see in image debug option available below your program.








2-When you click on debug option two option will enable debug and add watch.








3-Here you perceive one more option ADD WATCH. Using this button you can watch variable values and how those values change during debugging. It helps you to optimize how values changes in a variable. when you click on watch button another window will open,like this.

here is example of how to use watch function.












4- How to use breakpoints.
  breakpoints is another significant part of debugging. Breakpoints used to stop execution process at particular line of your program. This is the best way to find and get rid of errors.
  To use breakpoints you just have to click on numbers which is in left of your program when you click at this point a red round mark will appear. 
    


5- Now click the run button then you will see some more option below your program.initially program will stop at your first breakpoint after that you have option either execute it step by step or run all program.

No comments:

Post a Comment

Compiler for C,C++ and Python {paste your programme to see the output}