指针,指针函数,指针数组的区别
生活随笔
收集整理的這篇文章主要介紹了
指针,指针函数,指针数组的区别
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
1、指針
#include<iostream> using namespace std;int main() {int a=2;int *p;p=&a;printf("%d\n",p);printf("%d\n",*p);return 0; }2、指針函數(shù)
#include<iostream> using namespace std;int *p(int a) {int *P;P=&a;return P; } int main() {printf("%d\n",p(2));printf("%d\n",*p(2));return 0; }3、指針數(shù)組
#include<iostream> using namespace std;int main() {int a=1,b=2;int *p[2]; //聲明指針數(shù)組int *p1,*p2;p1=&a;p2=&b;p[0]=p1;p[1]=p2;printf("%d\n",*p[0]);printf("%d\n",p[0]);printf("%d\n",*p[1]);printf("%d\n",p[1]);return 0; }創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎
總結(jié)
以上是生活随笔為你收集整理的指针,指针函数,指针数组的区别的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C/C++笔试面试题目(2021最新版)
- 下一篇: ArcGIS 10.2 Calculat