静态二维数组与指针数组

来源:互联网 发布:价签制作软件 编辑:程序博客网 时间:2024/05/16 04:44
// test_array.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include "stdio.h"//#include <iostream>//using namespace std;int _tmain(int argc, _TCHAR* argv[]){int **p_array;p_array=new int*[4];const int height=4;const int width=4;int a[height][width];for(int i=0;i<height;i++){for(int j=0;j<width;j++){a[i][j]=i+j;//printf("%d\n",a[i][j]);}}int ar;//p_array=&a[0][0];p_array[0]=a[0];p_array[1]=a[1];p_array[2]=a[2];p_array[3]=a[3];for(int i=0;i<height;i++){       for(int j=0;j<width;j++)   {   printf("%d\n",p_array[i][j]);   printf("%d\n",a[i][j]);           cin>>ar;   //scanf("%d",ar);   }}return 0;}

原创粉丝点击