#include #include void foo(int a[]) { int *c; a++; // legal: type of a is int* std::cout << "sizeof int[] passed to function: " << sizeof(a) << std::endl; // same as sizeof(int*) std::cout << "typeid of int*: " << typeid(c).name() << std::endl; std::cout << "typeid of int[] passed to function: " << typeid(a).name() << std::endl; // pointer } void bar ( char a[][5] ) { char (*c)[5]; std::cout << "sizeof char a[][5] passed to function: " << sizeof(a) << std::endl; // same as sizeof(char(*)[5]) std::cout << "sizeof char a[][5] passed to function: " << sizeof(a[0]) << std::endl; // same as sizeof( char[5]) std::cout << "typeid of char(*)[5]: " << typeid(c).name() << std::endl; std::cout << "typeid of char[][5] passed to function: " << typeid(a).name() << std::endl; // pointer std::cout << "sizeof a[0]: "<< sizeof(a[0]) << std::endl; } int main() { int a[] = {2,3,4}; std::cout << "Sizeof int[3]: " << sizeof(a) << std::endl; // 3*sizeof(int) std::cout << "typeid(int[]): " << typeid(a).name() << std::endl; foo(a); std::cout << "---------------------------------" << std::endl; char b[3][5]; std::cout << "size: char b[3][5]: " << sizeof(b) << std::endl; // 3*5*sizeof(char) std::cout << "sizeof b[0]: " << sizeof(b[0]) << std::endl; // 5*sizeof(char) bar (b); }