Debugging Howto
I am new to C and at the moment I am using MS Visual C ++ 6.0. I am currently working on sorting algorithms and I want to automatically keep track of the values ββof each variable. This might give me insight into how the algorithm does the heavy lifting. That is, I don't want to write what comes out of what is on paper :) Are there any operators or functions for debugging purposes like var_dump () in PHP? or How can I improve my debugging abilities? Any other newbie debugging tools? or any good guides on using the built-in Visual C ++ debugger? Thank!..
In Visual C ++, you can set breakpoints on lines of code that you wrote using the F9 key. To the left of this line, you will see a small red dot. Then press F5 to compile and run.
f10 steps line by line. I think F11 goes into method.
You can also do output traces and debug lines in the output window if you like.
When you set breakpoints, you can watch the variables in the window - and I think the ones on the stack will automatically be in the stack / auto variable window. I'm sorry that I don't have VC6 right now to give more details or screenshots.
source to share
I think what you are looking for is called "Clock" in Visual Studio. You can add expressions (such as variable names) as items to view, and their values ββare automatically updated as the code passes. You may also be interested in the Locals debug window, which resembles a clock, except that it is populated with any variables local to the current scope.
Here's a quick tutorial on using Locals and Watches that I found via Google. Also check out this other SO question on best practices for debugging .
source to share
printf
/ fprintf
is the easiest debugging tool to use. It's much easier to analyze what happens if your program registers its activity. I prefer logging for visual debuggers because it is less interactive and allows me to analyze what happened after the program was run.
PS. Better not to pollute stdout and pipe the debug output to a file or stderr.
source to share