I have a very basic C program, and confused with its output:
#include<stdio.h>
int main() {
int i;
char s[] = "K";
for(i=0; s[i]; i++); {
printf("%d ", i);
printf("%c ", s[i]);
}
}
It outputs i value as 1, but as per one of the answer from this thread: Difference between pre-increment and post-increment in a loop?
int i = 0; // Initialization
loopStart:
if (i < 5) // Condition
{
Output(i);
i++ or ++i; // Increment
goto loopStart;
}
Increment happens after the Output(i) (equivalent to printf("%d ", i);), Then how i's value comes as 1 but not 0?