Here’s a C riddle: The following program was obviously expected to assign 1 to all the prime indices in the array and 0 to all the others. However, it enters an infinite loop. Explain. #define ARR_SIZE 10 IsPrime(n) int n; { int i; for (i = 1; i < n; ++i) if (n % i == 0) return 0; return 1; } main() { int arr[ARR_SIZE]; int it; ...
I gave a 3-hour presentation today on C++ debugging techniques, with a focus on production debugging. I’d like to share with you the demos I’ve shown during the session with a brief walkthrough so that you can repeat what I did in class. (I have intentionally omitted the debugger spew and any screenshots so that this still remains somewhat of an interesting challenge.) First of all, download the demo solution (30KB), unzip and open with Visual Studio 2008 (the code should work on Visual...