/**************************************************************************** * buggy-4.c * * David J. Malan * malan@harvard.edu * * Should increment a variable, but doesn't! * Can you find the bug? ***************************************************************************/ #include // global variable int x; // function prototype void increment(void); int main(void) { printf("x is now %i\n", x); printf("Initializing...\n"); x = 1; printf("Initialized!\n"); printf("x is now %i\n", x); printf("Incrementing...\n"); increment(); printf("Incremented!\n"); printf("x is now %i\n", x); } /** * Increments x. */ void increment(void) { int x = 50; x++; }