The following program prints this, which is what I want it to do:
Code:
#include <stdio.h>
#define MAX_TERMS 5
int ret_one(int);
int call_counter;
int main()
{
int i;
for(i = 1; i <= MAX_TERMS; i++, call_counter = 0) {
printf("%d", ret_one(i));
printf("%4d\n", call_counter);
}
return 0;
}
int ret_one(int num)
{
call_counter++;
return 1;
}
but when I use a single printf statement in the loop like this :
Code:
for(i = 1; i <= MAX_TERMS; i++, call_counter = 0) {
printf("%d%4d\n", ret_one(i), call_counter);
}
it prints this :
I don't know why call_counter is printed as 0, I watched it in the debugger and its value is 1 when it's passed as an argument to printf, but it still prints out as 0. I tell you, these little things...