- #include <stdio.h>
- int main(int argc,char ** argv)
- {
- char *p;
- printf("************************************\n");
- printf("p=%d,it is an address\n",p);
- p='\0';
- printf("p='\'0,print p= %c\n",p);
- p='0';
- printf("p='0',print %c! \n\n\n",p);
- char *p1;
- printf("************************************\n");
- p1="adcdefg";
- printf("p1 can print them '%s'\n\n\n",p1);
- char *p3;
- printf("************************************\n");
- p3=&("abcdefg"[5]);
- printf("p3=&(''abcdefg''[5]) print: %s\n",p3);
- char str[] = "adcedfg";
- p3=&str[5];
- printf("'p3=&str[5]' will print %s too \n",p3);
- char *p4;
- printf("************************************\n");
- *p4="abcdefg"[5];
- printf("print p4= %s\n",*p4);
- char *p5;
- p5=&("abcdefg"[5]);
- printf("%s\n",p5);
- return 0;
- }
运行效果:************************************
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
************************************
段错误