/**************************************************************************** * buggy5.c * * Computer Science 50 * David J. Malan * * Should increment a variable, but doesn't! * Can you find the bug? ***************************************************************************/ #include /* global variable */ int x; /* function prototype */ void increment(); int main(int argc, char * argv[]) { printf("x is now %d\n", x); printf("Initializing...\n"); x = 1; printf("Initialized!\n"); printf("x is now %d\n", x); printf("Incrementing...\n"); increment(); printf("Incremented!\n"); printf("x is now %d\n", x); } /* * void * increment() * * Increments x. */ void increment() { int x = 10; x++; }