dyli指针初探

简介: #include stdio.h> int main(int argc,char ** argv) {         char *p;         printf("************************************\n");...
  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
************************************
段错误





相关文章
|
3月前
按字节赋值的memset
按字节赋值的memset
25 0
|
3月前
函数指针数组指针(指向函数指针数组的指针)
函数指针数组指针(指向函数指针数组的指针)
21 2
|
8月前
|
C语言
C语言指针--指针中的const
C语言指针--指针中的const
59 0
|
8月前
|
存储 C语言 C++
深入了解指针,指针数组,数组指针。
深入了解指针,指针数组,数组指针。
|
9月前
|
人工智能 大数据 BI
指针及其应用2——数组指针、字符串指针
指针及其应用2——数组指针、字符串指针
|
5月前
指针(二)------字符指针+数组指针+指针与数组(传参)
指针(二)------字符指针+数组指针+指针与数组(传参)
31 0
|
6月前
|
存储
指针进阶(3) -- 关于sizeof和strlen的详细总结(下)
指针进阶(3) -- 关于sizeof和strlen的详细总结(下)
|
6月前
指针进阶(3) -- 关于sizeof和strlen的详细总结(上)
指针进阶(3) -- 关于sizeof和strlen的详细总结(上)
|
6月前
|
存储
指针进阶(3) -- 关于sizeof和strlen的详细总结(中)
指针进阶(3) -- 关于sizeof和strlen的详细总结(中)
|
7月前
|
存储
串拷贝(strcpy)和内存拷贝(memcpy)
串拷贝(strcpy)和内存拷贝(memcpy)
42 0