Q:

C - String vs. Array in for condition

today i was trying to make a simple "program" in C, and i want to do following: When you enter Uppercase string, the program will transform all characters to lowercase. But i stupped to curiosity.
char uppword[26];
int i;
printf("Gimme a word in uppercase.: ");
scanf("%s", uppword);
for (i=0; i < uppword[i]; i++){
    uppword[i] = uppword[i] + 32;
}

printf("%s", uppword);

return 0;

As you can see, in for loop is a condition i < uppword[i], but i dont know, why this is works. In other way, i can replace this condition by i < strlen(uppword), and it will be also works. But i don't think that this is same as array. Why this Array works? The "i" in array is on the beginning 0, so the condition is not TRUE, and it can't be proceeded. 

A:

uppword[i] will be 0 at the end of the string (scanf does that for you unless you've tried to read too many characters in which case the compiler might eat your cat). i < 0 will be 0 at that point. Subject to some assumptions, it is 0 only at that point: These assumptions are (i) uppword has at most less than 32 characters (you've allowed for 25 plus a nul-terminator), and (ii) in ASCII at least you typically don't encounter characters less than 32 (as they are the control set).
Clever, if a little hard to read.
The smart alec programmer might also want to consider the fact that this code assumes ASCII encoding, and is therefore not portable C.
Consider using strlen instead, but pre-compute that: don't include it as the loop conditional as you'll then convert an O(N) process to an O(N*N) process - only a compiler from a divinity would know that strlen doesn't change between iterations, given that your loop body mutates the string.

