So I wrote this code
char *word = "Metal Gear";
int counter = 0;
printf("word = ");
for(;;)
{
printf("%c", *word);
*(word++);
counter++;
if(*word == '\0')
break;
}
The variable counter to count the length of my word string.
How come this code does not print the null character?
I know that I told it to break once it encounters a null character, but my print statement is before the if clause, so shouldn't it print it then break out of the loop.
How come there's no difference if the if clause is at the very beginning of the for loop ?!
update: while I'm at it, does c allow variable length for arrays or not?
I'm confused by this because I read that it allows it and that it doesn't.
My assumption that c99 allows it but many articles and blogs haven't been updated since the release of c99 standard. Am I correct?