首页 > 学院 > 开发设计 > 正文

指针初始化注意事项

2019-11-06 09:13:21
字体:
来源:转载
供稿:网友

//指针不能未初始化直接使用,例如int *p=3这种方式,也不可以int *p;*p=3(因为*p的作用是把p指向的地址中的值取出来

#include<iostream>#include<stdlib.h>int main(){ using namespace std; int T; cin>>T; while(T--){ int n; cin>> n; int *p; p=&n; cout<<*p;} system("pause"); return 0;}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表