// There is a problem in this source file related to // accessing array indices. First, compile this file // by issuing the following command: // // gcc -g -Wall -std=gnu99 -o conditional conditional.c // // Next, run the program under GDB: // // gdb ./conditional // // Set a conditional breakpoint to take a look at the // status of the variables in PrintIndex where the // problem occurs. Even if you immediately see what // the issue is, it would still be good to practice // using GDB anyway. // // Some commands you'll want to use: // "b" to set a breakpoint // "n" to move to the next statement, skipping over // function calls // "s" to step to the next statement, not skipping // over function calls // "p" to print values // // The section slides have more information, and you // can also use "help [command]" within GDB to see // how to use them. #include static void PrintIndex(int* array, char index) { printf("%d\n", array[index]); } int main(int argc, char* argv[]) { int stack_array[256]; for (int i = 0; i < 256; ++i) { stack_array[i] = i; PrintIndex(stack_array, i); } return 0; }