All values ββfrom s1 to s5 are not char ; they point to char . So, you are comparing the memory addresses of each line, not the lines themselves.
If you display the addresses in this way, you can see what the comparison operators actually work for:
#include <stdio.h> int main() { char *s1 = "Andreas"; char *s2 = "Andreas"; char s3[] = "Andreas"; char s4[] = "Andreas"; char *s5 = "Hello"; printf("%p\n", s1); // 0x80484d0 printf("%p\n", s2); // 0x80484d0 printf("%p\n", s3); // 0xbfef9280 printf("%p\n", s4); // 0xbfef9278 printf("%p\n", s5); // 0x80484d8 }
Exactly where the lines are allocated in memory is implementation-specific. In this case, s1 and s2 point to the same static memory block, but I would not expect this behavior to be portable.
source share