So I have the following code:
#include <stdio.h>
int f(char *c)
{
static int i=0;
for (;*c;*c++=='a'?i--:i++);
return i;
}
int main()
{
for(int i=1; i<4; i++)
printf("%d:%d\n", i, f("buba"));
return 0;
}
I already know what is gonna be written in the output of the program, but my question is why? If you edit the string and make subtle changes, the output remains the same which is:
1:2
2:4
3:6