c++数组与指针

来源:互联网 发布:域名访问网站加端口号 编辑:程序博客网 时间:2024/06/14 02:55
#include <iostream>using namespace std;int main(){    int haitao[] = { 11, 2, 5 };    haitao[2] = *haitao;//数组变量可以用作指针,这个指针指向数组中第一个元素    cout << haitao[0]<<    haitao[1] <<   haitao[2]<< endl;    system("pause");    return 0;}

这里写图片描述



可以通过增加指针的值,来查找数组中其它元素


#include <iostream>using namespace std;int main(){    int haitao[] = { 11, 2, 5 };    haitao[2] = *(haitao+1);//数组变量其实又是一个指针,这个指针指向字符数组的第一个    cout << haitao[0]<<    haitao[1] <<   haitao[2]<< endl;    system("pause");    return 0;}


这里写图片描述


FR:海涛高软(hunk Xu) QQ技术交流群:386476712