Technically, you are comparing string addresses. So without optimisations, the expected answer is "No" (two different strings, hence two addresses).
However, most modern compilers perform string interning (merging identical constants strings), in which case the answer would be "Yes". Note this only happens for string literals.
For instance, GCC 4.9.2 does this by default:
#include <stdio.h>
int
main()
{
char *ptr1 = "abc";
char *ptr2 = "abc";
printf("%p\n%p\n",ptr1,ptr2);
if (ptr1 == ptr2) printf("yes\n");
}
gcc -o /tmp/file /tmp/file.c
/tmp/file
0x400660
0x400660
yes
Interestingly, behaviour is different (i.e. no interning) when declaring the variables char ptr1[]
and char ptr2[]
. This is because, in that case, the compiler actually places the strings on the stack (see here).
As stated in comments, the proper way to compare strings is strcmp
and related functions.