#include <iostream>
using namespace std;

int main()
{
	int a[] = {1, 2, 3};
	cout << sizeof(a) << endl; // 12
	cout << sizeof(a[0]) << endl; // 4

	// 指针数组
	const char *p[] = {"ab", "def", "adgbgdegsdggf"};
	cout << sizeof(p) << endl; // 12
	cout << sizeof(p[0]) << endl; // 4

	// 二维数组
	char test[][20] = {"ab", "def", "adgbgdegsdggf"};
	cout << sizeof(test) << endl; // 60
	cout << sizeof(test[0]) << endl; // 20

	return 0;
}


本文转载:CSDN博客