关于"=="操作符的施用

关于操作符的使用大神们给讲讲这个操作符怎么用吧,处理标准的数据类型外,还能比较什么类型?怎样比较

关于"=="操作符的使用
大神们给讲讲==这个操作符怎么用吧,处理标准的数据类型外,还能比较什么类型?
怎样比较?下面还有3段摘抄于C99标准的辅助信息。


#include <stdio.h>//printf
#include <stdlib.h>//exit

typedef struct __st
{
int a;
char b;
}ST;

int main(int argc, char *argv[])
{
char *s = "abc";
char as[] = "abc";
ST sta = {1, 2};
ST stb = {1, 2};

if (as == s){printf("equal\n");}else{printf("Not equal\n");}

if (as == "abc"){printf("equal\n");}else{printf("Not equal\n");}

if (s == "abc"){printf("equal\n");}else{printf("Not equal\n");}

if ("abc" == "abc"){printf("equal\n");}else{printf("Not equal\n");}

//if (sta == stb){printf("equal\n");}else{printf("Not equal\n");}

exit(0);
}

运行结果:
Not equal
Not equal
equal
equal


C99
Where an operator is applied to a value that has more than one object representation,
which object representation is used shall not affect the value of the result.43) Where a
value is stored in an object using a type that has more than one object representation for
that value, it is unspecified which representation is used, but a trap representation shall
not be generated.

43) It is possible for objects x and y with the same effective type T to have the same value when they are accessed as objects of type T, but to have different values in other contexts. 
In particular, if == is defined for type T, thenx == ydoes not imply that memcmp(&x, &y, sizeof (T)) == 0.Furthermore,x == ydoes not necessarily imply that x and y have the same value; other operations on values of type T may distinguish between them.

14 EXAMPLE 6 Like string literals, const-qualified compound literals can be placed into read-only memory and can even be shared. For example,
(const char []){"abc"} == "abc"
might yield 1 if the literals’storage is shared. C ==
[解决办法]
字符串比较,其实是比较他们的地址。
    char *s = "abc"; // abc作为常量放在全局数据区,位置固定
    char as[] = "abc"; //放置在栈区
if (as == "abc"){//凡是这些使用"abc"都是常量放在全局数据区呢。


所以 s和as的字符地址不一样
    as和"abc"也不一样
     s和"abc"都指向一个常量
   "abc"和"abc"也一样,也指向同一个常量。
[解决办法]
对字符指针和字符串用==,比较的不是它们的内容。。是它们本身的地址。。