报错不懂error C2440: '=' : cannot convert from 'int [3][4]' to 'int *'

问了下人还是不明白其中的含义。谢谢指教


#include <iostream>
#include <iomanip>
using namespace std;
int main()
{ int   a[3][4] = {{1,3,5,7},{9,11,13,15},{17,19,21,23}};
   int   *p;
   int  count=0;
  
   for(*p=a;p<=a[2]+3;p++)   //error
      { cout<<setw(2)<<*p<<" ";
              count++;
        if(count%4==0) cout<<endl;
           }
 return 0;
 }

二维数组在内存是按行线性排列的,你可以用指针依次访问各个元素

#include <iostream>
#include <iomanip>

using namespace std;

int main()
{
    int a[3][4] = {{1, 3, 5, 7}, {9, 11, 13, 15}, {17, 19, 21, 23}};
    int *p;
    int count = 0;

    for (p = &a[0][0]; p <= &a[2][3]; p++)
    {
        cout << setw(2) << *p << " ";
        count++;
        if (count % 4 == 0)
            cout << endl;
    }
    return 0;
}
$ g++ -Wall main.cpp
$ ./a.out
 1  3  5  7 
 9 11 13 15 
17 19 21 23

二维数组,明显得用二级指针,而且*p=a是什么鬼?