首页 > 编程语言 > 详细

win编程实践(4)【c++】- 多维数组指针

时间:2015-11-24 11:09:36      阅读:316      评论:0      收藏:0      [点我收藏+]

//ConsoleApplication1.cpp : 定义控制台应用程序的入口点。

//

 

#include "stdafx.h"

#include <iostream>

 

 

using std::cout;

using std::endl;

using std::cin;

 

 

本博客所有内容是原创,如果转载请注明来源

http://blog.csdn.net/myhaspl/

 

int main()

{

    char temp;

    int x[2][4];

    for (int i = 0; i < 2; i++) {

        for (int j = 0; j < 4; j++) {

            x[i][j] = i*10+j;

        }

    }

    int *x1ptr = &x[0][0];

    int (*x2ptr)[4] = x;

    for (; x2ptr <= &x[1]; x2ptr++) {

        for (int j = 0; j < 4; j++) {

            cout << (*x2ptr)[j]<< "  ";

        }

        cout << endl;

    }

    for (int i = 0; i < 2; i++) {

        for (int j = 0; j < 4; j++) {

            cout << *(*(x+i)+j) << "  ";

        }

        cout << endl;

    }

    for (int i= 0; i < 2; i++) {

        for (int j = 0; j < 4; j++) {

            cout << *(x1ptr + i*4+ j) << "  ";

        }

        cout << endl;

    }

    cin >> temp;

    return 0;

}       

win编程实践(4)【c++】- 多维数组指针

原文:http://blog.csdn.net/myhaspl/article/details/50008895

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!