Cannot cast array to pointer

前端 未结 8 981
陌清茗
陌清茗 2020-12-14 23:41

I have the following source:

#include 
using namespace std;

void main(int j)
{
    char arr[10][10];
    char** ptr;
    ptr = arr;
}
         


        
8条回答
  •  甜味超标
    2020-12-15 00:12

    Arrays are NOT just pointers -- arrays are arrays. Arrays are not first-class types, however, so you can't use them in many places. The thing that causes your confusion is that array names CAN be implicitly converted into pointers to the array's first element, which means that you can use an array in many places where you need a pointer and it 'just works'. This, however, is not one of those places.

提交回复
热议问题