#include <stdio.h>
int main (void)
{
/*
错误2(出错):int类型与int * 类型不匹配,系统分配的垃圾值
*/
int i= 5;
int *p;
int *q;
p = &i;
// *q = p;//error 语法编译会出错
// *q = *p;//给出警告,因为q并没有指定内存地址,与错误一如出一辙
p = q;//q是垃圾值,q赋给p,p也变成垃圾值
printf("%d\n",*q);
/*
q的空间是属于本程序,所以本程序可以读写q的内容
但是q内部是垃圾值,那么本程序不能读写*q的内容
*/
return 0;
}
报错信息:
[Warning] assignment makes integer from pointer without a cast
赋值使整数来自指针,而不需要强制转换