Original Post
When most people learn programming, they don't learn the finer points of the craft, such as debugging. (I've heard stories of people making it all the way through their comp-sci course without knowing there was such a thing as a debugger.) Here are a some basic debugging tips to make your life easier. Please note, I'm just a begginer, so my knowlege is severely limited... If you have any advice of your own, please share it here. The following are based on vc++ 7 (.net) I would imagine that other compilers have comprarable debugging features, but I haven't actually used them. Breakpoints - Breakpoints allow you to pause your program during execution so that you can take a look inside, check variable values, etc. Step into/over/out - Stepping makes your program run one step at a time, allowing you to follow the program's flow as it executes. That way you can track how it deals with certain conditions, desision gates (if/else), or variable values. Flagging - One way to track where a program goes is to make certain functions throw up a flag when they are called. Probably the easiest way to do this is to get them to print a short message, such as "init called", "creating object", "deleting texture". I personally use these to track resource management, to make sure that everything is being cleaned up properly. The problem with this is that once you're done with the testing, you want to get rid of the flags, and it's a real pain to go through all your code, looking for these flags to remove them. Luckilly, there's another way. At the begining of the program, we tell the compiler that we are doing debug. #define DEBUG then, when we set a flag, we do it as follows: #if defined(DEBUG) printf("Output message here"); #endif This way, the program looks to see if we're still debugging before compiling the print line. When we want to get rid of the flags, we just remove the #define DUBUG, and the compiler will ignore the flags. [Edited by - methinks on April 15, 2005 11:10:16 AM]