What is array decaying in C/C++?

Arrays and pointers work quite similarly in C/C++. But there are some subtle differences. For example, the sizeof operator works quite differently on the two. When you convert an array in a pointer,



int main() {
   const int a[] = { 2, 3, 5, 7, 11 };
   const int* p = a;
   std::cout << ( sizeof(p) != sizeof(a) );


This gives the output −


The sizeof operator on the pointer actually gives the size of the pointer rather than that of the array. This loss of ability of a pointer is called "decay".