中骏蓝湾半岛二手房:指针与数组、字符串的问题。

来源:百度文库 编辑:神马品牌网 时间:2024/05/07 16:34:40
如果将一个字符串的地址赋给一个指针变量?
main()
{
char c[1];
char *p;
c[0]="show me the money";
p=&c;
printf("%s",*p);
getch();
}

main()
{
char c[1];
char *p;
c[0]="show me the money"; //这里错了,不可能这样写的,一个CHAR怎么能存一个字符串呢?
p=&c;
printf("%s",*p);
getch();
}

应该如下这样写:
main()
{
char c[]="show me the money";
char *p;
p=c;
printf("%s",*p);
getch();
}