// Build like this: // g++ debugger_demo.cpp -g #include using namespace std; /* run - Runs the program * break - Stops the program at a particular line * print - Prints out the value of anything you like * ctrl + d - End of file, exits the debugger * display - Print out the value of a variable while we move through the program * next - Run the next line * continue - Resume running the program * set - Change the value of a variable * p/x - Print values in hexdecimal */ void foo(int *array){ cout << array[9] << endl; } int main(){ int array[10] = {4, 8, 12, 16, 20, 24, 28, 32, 36, 40}; int sum = 0; for(int i = 0; i < 10; i++) sum += array[i]; // Break it right here foo(array); int *p_sum = (int*)sum; cout << *p_sum << endl; return 0; }