- #include<stdio.h>
- void fun()
- {
- char str[]="abcedfe is apha",*p;
- p=str;
- printf("%s\\n",str);/*以字符串格式输出字符数组*/
- printf("%s\\n",p);/*输出指针变量所指的内容值*/
- }
- void fun2()
- {
- char str[]="abcedfe is apha";/*字符数组*/
- char *p;/*指针变量*/
- p=str;/*指针变量出书啊地址为字符数组的起始地址*/
- printf("%s\\n",str);/*以字符串格式输出字符数组*/
- for(p=str;*p!='\\0';p++)
- {
- printf("%c",*p);/*以字符格式输出数组*/
- }
- }
- void main()
- {
- fun();
- printf("--------------\\n");
- fun2();
- system("pause");
- }
- //该片段来自于http://www.codesnippet.cn/detail/310120132019.html
来源: http://www.codesnippet.cn/detail/310120132019.html