1.1 Ö¸ÕëµÄÈýÒªËØ
ÔÚÄÚ´æÖÐÉêÇëÒ»¿é¿Õ¼ä(³ýÁËÄÚ´æ¹ÜÀíº¯ÊýÒÔÍâ)¡£ÔÚ¶¨Òå±äÁ¿£¬¶¨Òå±äÁ¿ ·ûºÏ---> Êý¾ÝÀàÐÍ ±äÁ¿Ãû
1. ±äÁ¿Ãû·ûºÏ±êʶ·ûÃüÃû¹æÔò£¬È¥µô±äÁ¿ÃûʣϵľÍÊDZäÁ¿µÄÀàÐÍ
Êý¾ÝÀàÐÍ [³¤¶È] ------------->Êý×éÀàÐÍ£¬ Êý×éÔªËصÄÀàÐÍ
Êý¾ÝÀàÐÍ * ----------->Ö¸ÕëÀàÐÍ Ö¸ÕëÖ¸Ïò¶ÔÏóµÄÀàÐÍ
Êý¾ÝÀàÐÍ (²ÎÊýÁбí) --------->º¯ÊýÀàÐÍ º¯Êý·µ»ØÖµÀàÐÍ
2.
1) ÔÚÊý×éµÄÉùÃ÷ÖУ¬È¥µô Êý×éÃû[³¤¶È] ʣϵľÍÊÇÊý×éÔªËصÄÀàÐÍ
2) ÔÚÖ¸ÕëµÄÉùÃ÷ÖУ¬È¥µô *Ö¸ÕëÃû ʣϵľÍÊÇÖ¸ÕëÖ¸ÏòµÄ¶ÔÏóÀàÐÍ
3) ÔÚº¯ÊýµÄÉùÃ÷ÖУ¬È¥µô º¯ÊýÃû(²ÎÊýÁбí) ʣϵľÍÊǺ¯ÊýµÄ·µ»ØÖµÀàÐÍ
3. ÔÚ¸´ÔÓÊý¾ÝÀàÐ͵Ķ¨ÒåÖУ¬ÓгöÏÖ * [] ()£¬½«Æäµ±×öÔËËã·û´¦Àí£¬¸ù¾ÝÔËËã·ûÓÅÏȼ¶ºÍ½áºÏÐÔÈ·¶¨±êʶ·ûÓÅÏȸú˽áºÏ
±êʶ·û[ÕûÐͳ£Á¿] ------>Êý×é Êý×éÔªËصÄÀàÐÍ
*±êʶ·û ------->Ö¸Õë Ö¸ÕëÖ¸Ïò¶ÔÏóµÄÀàÐÍ
±êʶ·û(²ÎÊýÁбí) ------->º¯Êý º¯Êý·µ»ØÖµÀàÐÍ
³ýµô
½á¹¹ÌåÀàÐÍ struct ½á¹¹ÌåÃû
¹²ÓÃÌåÀàÐÍ union ¹²ÓÃÌåÃû
ö¾ÙÀàÐÍ enum ö¾ÙÃû
ÄÚ´æ¹ÜÀíº¯Êý malloc calloc
»ù±¾Êý¾ÝÀàÐÍ int char double float
Ö¸ÕëÃû £º Ö¸ÕëÃû·ûºÏ±êʶ·ûµÄÃüÃû¹æÔò
Ö¸ÕëÀàÐÍ£º ½«Ö¸ÕëÃûÈ¥µô£¬Ê£ÏµľÍÊÇÖ¸ÕëµÄÀàÐÍ Êý¾ÝÀàÐÍ *
Ö¸ÕëÖ¸ÏòµÄ¶ÔÏóµÄÀàÐÍ£ºÈ¥µô *Ö¸ÕëÃû ʣϵľÍÊÇÖ¸ÕëÖ¸ÏòµÄ¶ÔÏóµÄÀàÐÍ
int *fun[3]; //fun[3]---------->Êý×é
//È¥µô fun[3]ʣϵľÍÊÇÊý×éÔªËصÄÀàÐÍ int * ----->Ö¸Õë
//Ö¸ÕëÊý×é
int *fun(int ) //fun(int) --------->º¯Êý
//È¥µô fun(int),ʣϵľÍÊǺ¯Êý·µ»ØÖµÀàÐÍ int *
//Ö¸Õ뺯Êý
int (*fun)(int)
//*fun ---------¡·Ö¸Õë
//È¥µô *fun , ʣϵľÍÊÇÖ¸ÕëÖ¸ÏòµÄ¶ÔÏóµÄÀàÐÍ int (int)---->º¯ÊýÀàÐÍ
int (*fun)[3]
//*fun---->Ö¸Õë
//È¥µô *fun , ʣϵľÍÊÇÖ¸ÕëÖ¸ÏòµÄ¶ÔÏóµÄÀàÐÍ int [3]------->Êý×éÀàÐÍ
int (*fun[3])(int);
//fun[3]----->Êý×é
//Êý×éÔªËصÄÀàÐÍ£º int (*)(int);
//º¯ÊýÖ¸ÕëÊý×é
1.2 Ö¸ÕëµÄ´óС
Ö¸ÕëËùÕ¼µÄ¿Õ¼ä´óС£¬ÓÉÖ¸Õë±¾Éí¾ö¶¨£¬¸úÖ¸ÕëÖ¸ÏòµÄ¶ÔÏóµÄÀàÐÍÎ޹أ¬Ò»°ãÖ¸ÕëËùÕ¼µÄ¿Õ¼ä´óСΪ4¸ö×Ö½Ú£¬²»Í¬±àÒëÆ÷ËùÕ¼¿Õ¼ä´óС²»Ò»Ñù£¬
Ö¸ÕëµÄÆ«ÒÆÓɶ¨ÒåʱָÕëÖ¸ÏòµÄ¶ÔÏóµÄÀàÐ;ö¶¨Æ«ÒƳ¤¶È£¬¶ø²»ÊÇÓÉÖ¸Õëʵ¼ÊÉÏÖ¸ÏòµÄ¶ÔÏóÀàÐ;ö¶¨£¬Ò»°ã¶¨ÒåʱָÕëÖ¸ÏòµÄ¶ÔÏóÀàÐ͸úʵ¼ÊÉÏÖ¸ÕëÖ¸ÏòµÄ¶ÔÏóÀàÐͱ£³ÖÒ»ÖÂ
int main() { int a = 1234567; // 0000 0000 0001 0010 1101 0110 1000 0111 int *p = &a; char *pf = &a;
pf = pf+1;
*pf = *pf +1; // 1101 0110 + 1 --->1101 0111 //0000 0000 0001 0010 1101 0111 1000 0111 printf("%d\n",*pf); //215 //127 -41 printf("%d\n",*p); printf("%d\n",a); //1234823
printf("=============================\n");
unsigned int c = 0XAABBCCDD; unsigned char *pt = &c; unsigned int d = *pt;
*pt = *(pt+3); *(pt+3) = d; printf("%#X\n",c); } |
int main() { char buf[] = "werr\t tyui"; char *p = buf;
//strlenÇó×Ö·û´®³¤¶Èº¯Êý printf("%d\n",strlen(buf)); //ÒÔbufΪÊ×µØÖ·£¬Í³¼Æ×Ö·û´®×Ö·ûµÄ¸öÊý 10 printf("%d\n",strlen(p+2)); //ÒÔp+2ΪÊ×µØÖ· ͳ¼Æ×Ö·û´®×Ö·ûµÄ¸öÊý printf("%d\n",strlen(p)); //ÒÔpΪÊ×µØÖ·£¬Í³¼Æ×Ö·û´®×Ö·ûµÄ¸öÊý 10
//sizeof ÇóÊý¾ÝËùÕ¼¿Õ¼ä´óС //ÇóÊý¾ÝÀàÐÍËùÕ¼¿Õ¼ä´óС printf("%d\n",sizeof(buf)); //char [³¤¶È],³¤¶ÈÓɳõʼ»¯Áбí¾ö¶¨ 11 printf("%d\n",sizeof(buf[3]));//buf[3]--->ÔªËØ£¬ ÔªËØÀàÐÍ char
printf("%d\n",sizeof(p)); //pµÄÀàÐÍ---->char * printf("%d\n",sizeof(*p)); //*p ==buf[0] ÔªËØÀàÐÍ char } |