關於指標的一點兒小知識

來源:互聯網
上載者:User

博主: 這個娃說的挺對胃口的,轉了

1:轉自:http://www.360doc.com/content/11/0925/16/6527018_151129737.shtml

很多人把指標說的洪水猛獸似的,其實就那麼回事兒嘛

 

2:字元指標與整形指標的一點兒分析

轉自:http://blog.csdn.net/ghost1236/article/details/6309809 

不錯滴。

 

 

#include<stdio.h>
#include<stdlib.h>
/*int main(void)
{
 int *pi;
 char * pc;
 long * pl;
 char a[]="abcdefg";
 int b = 10000;
 printf("the sizeof int  * is %d \n",sizeof(pi));
 printf("the sizeof char * is %d \n",sizeof(pc));
 printf("the sizeof long * is %d \n",sizeof(pl));
 pi = a; 
 printf("array: the sizeof int   is %s \n",pi);
 pc = a;
 printf("array:the sizeof char  is %s \n",pc);
 pl = a; 
 printf("array:the sizeof long  is %s \n",pl);
 *pi = b;
 printf("char number: the sizeof int is %d \n",*pi);
 *pc = b;
 printf("char number: the sizeof char is %d \n",*pi);
 *pl = b;
 printf("char number: the sizeof long is %d \n",*pi);

 return 0;
}*/

/*int main(int argc, char *argv[])
{

  char day[15] = "abcdefghijklmn";
  char* strTmp = "opqrstuvwxyz";

  printf("&day is %x\n",&day);
  printf("&day[0] is %x\n",&day[0]);
  printf("day is %x\n",day);
 
  printf("\n&strTmp is %x\n",&strTmp);
  printf("&strTmp[0] is %x\n",&strTmp[0]);
  printf("strTmp is %x\n",strTmp);
 
  getchar();
  return 0;
}*/
int main(int argc, char *argv[])
{
 char *c = "123456";
 int  *i = "123456";

 printf("&c is %d\n",&c);
 printf("c is %x\n",c);
 printf("*c is %s\n",c);
 c++;
 printf("c++\n&c is %d\n",&c);
 printf("c is %x\n",c);
 printf("*c is %s\n",c);
 *c++;
 printf("*c++\n&c is %d\n",&c);
 printf("c is %x\n",c);
 printf("*c is %s\n",c);

 printf("\n\n\n&i is %d\n",&i);
 printf("i is %x\n",i);
 printf("*i is %s\n",i);
 i++;
 printf("2222 i++\n&i is %d\n",&i);
 printf("i is %x\n",i);
 printf("*i is %s\n",i);
 
 
 printf("3333*i++\n  &i is %d\n",&i);
 printf("i is %x\n",i);
 printf("*i is %s \n",i);

    return 0;
}

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.