C不解!!

来源:百度知道 编辑:UC知道 时间:2024/05/26 23:37:54
#define s 30;
main()
{int *p=s;
printf ("%d",*p);
getch()
} 运行结果为14392 帮忙解释一下吗~!~!

没死机就知足吧

相当於p指向地址号为30的地址内存
输出该内存内容

你想要这样吗?
const int s = 30;
main()
{int *p=&s;
printf ("%d",*p);
getch()
}

大哥这能运行吗?怎么可会有运行结果?!
cannot convert from 'const int' to 'int *'
改成如下形式
#include<stdio.h>
main()
{
const int s = 30;
const int *p=&s;
printf ("%d\n",*p);

}

宏定义里面的S是没有数据类型的。