二维数组指针,二维数组作参数函数调用简单实例(c/c++)

来源:互联网 发布:徐老师淘宝店的地址 编辑:程序博客网 时间:2024/05/17 09:24
#include <iostream>using namespace std;int matrix[][4] = {{1, 2, 8, 9}, {2, 4, 9, 12}, {4, 7, 10, 13}, {6, 8, 11, 15}};void test(int* p){    cout << *(p + 6) << endl;    cout << p[6] << endl; //与上一行等价}int main(){    //cout << *(*matrix + 6) << endl;    //cout << *(*(matrix + 2)) << endl;    test((int*)matrix); // 二维数组作参数    return 0;}

原创粉丝点击