Good programmers: how do you debug code?

<p>Strategies? Tips? Techniques?</p>

<p>I mostly just use lots and lots of printf statements, but that usually takes me forever and a day. (And I have to send my mentor a graph in like three hours, and have reason to suspect the program’s buggy, and three hours is substantially less than “forever”…)</p>

<p>because you said printf, I assume you’re using C++? Visual studio has a wonderful debugger if you can get your hands an a copy of it. If you’ve never used a debugger before, you add break points to the code. Once the program runs through and reaches that line of code where the breakpoint is, you progress through the program 1 line at a time, allowing you to check the values of any variables, including all cells within a string or an array.</p>

<p>If, in fact, you are speaking about C++, I would have to agree with the above comment. During a computer programming course I took this summer, we used a free Visual Studio program from Microsoft, which was competent and worked very well for debugging. The instructor said that the version that costs money works a bit better, but overall I can say that the debugging worked well. If I remember correctly, it listed the number of the line with the error, and if you double-clicked on the error listing, it took you to that line — a real time-saver. Sometimes the debugger errors are a little wacky or incorrect, but I would recommend it for the convenience.</p>

<p>Um, I use a debugger. C also has one (well, it works with C++ too) - gdb which I use, but it doesn’t really matter. But yea, that’s been really helpful for me, but it can still take a while - but it’s definitely a lot easier than just using printf statements.</p>

<p>visual studio is the way to go. but i’m assuming you’re talking about perl?</p>