dyli指针初探

  1. #include stdio.h>

  2. int main(int argc,char ** argv)
  3. {
  4.         char *p;
  5.         printf("************************************\n");
  6.         printf("p=%d,it is an address\n",p);
  7.         p='\0';
  8.         printf("p='\'0,print p= %c\n",p);
  9.         p='0';
  10.         printf("p='0',print %c! \n\n\n",p);


  11.         char *p1;
  12.         printf("************************************\n");
  13.         p1="adcdefg";
  14.         printf("p1 can print them '%s'\n\n\n",p1);


  15.         char *p3;
  16.         printf("************************************\n");
  17.         p3=&("abcdefg"[5]);
  18.         printf("p3=&(''abcdefg''[5]) print: %s\n",p3);
  19.         char str[] = "adcedfg";
  20.         p3=&str[5];
  21.         printf("'p3=&str[5]' will print %s too \n",p3);



  22.         char *p4;
  23.         printf("************************************\n");
  24.         *p4="abcdefg"[5];
  25.         printf("print p4= %s\n",*p4);

  26.         char *p5;
  27.         p5=&("abcdefg"[5]);
  28.         printf("%s\n",p5);

  29.         return 0;
  30. }


运行效果:

************************************
p=1307813,it is an address
p=''0,print p=
p='0',print 0!


************************************
p1 can print them 'adcdefg'


************************************
p3=&(''abcdefg''[5]) print: fg
'p3=&str[5]' will print fg too
************************************
段错误





上一篇:【转】用 PHP V5 开发多任务应用程序


下一篇:C/C++封装库ocicpplib调用Oracle存储过程的方法