# include "stdio.h"
# include "string.h"
# include "iostream.h"
void main()
{
//指针定义与赋值
int a=2;
int * p=NULL;
p=&a;
cout<<a<<endl;
cout<<&a<<endl;
cout<<*p<<endl;
cout<<p<<endl;
int str[3]={2};
int * p1=NULL;
p1=str;
cout<<*p1<<endl;
//常见错误(把指针当做字符串)
char * p=NULL;
char s[10]={0};//先要给指针赋值
p=s;
strcpy(p,"hello");
cout<<p;
//强制转换
int arr[5]={1,2,3,4,5};
char * p=NULL;
p=(char *)arr;
printf("%d",*(p+4*3));
for(int i=0;i<17;i++)
{
printf("%d\n",*(p+i));
}
}