String literals in C (e.g. "look") are stored somewhere in memory. When you use "look" in your code you're actually playing with a pointer to that stored memory. I don't know how familiar you are with pointers, but basically what you're doing is comparing 2 memory addresses when you do
if(input == "look").
So it's not comparing the contents of the strings, but the memory address of the strings. So:
Code:
char *ptr1 = "foo";
char *ptr2 = "foo";
printf("%d\n", ptr1 == ptr2)
that will print 0 since there's actually 2 "foo"s in memory and each pointer points to its own, but:
Code:
char *ptr1 = "foo";
char *ptr2 = ptr1;
printf("%d\n", ptr1 == ptr2);
that will print 1 because the value of ptr1 is equal to the value of ptr2 (they point to the same address).
You can also look at it like this:
Code:
int a = 5;
int b = 5;
printf("%d\n", a == b);
printf("%d\n", &a == &b);
The first printf() will print 1 because the values of a and b are the same, but the second printf() will print 0 because the address of a and b are not the same.
So to sum up, strings in C are really just an address to the first character in the string. When you do
if(string1 == string2) you're comparing the memory addresses that the two strings point to, not the contents of the string.