1. 程式人生 > >指標和陣列面試解析(1)

指標和陣列面試解析(1)

 執行環境VS2017  執行系統32位

int a[] = { 1,2,3,4 }; 
printf("%d\n", sizeof(a));
printf("%d\n", sizeof(a + 0)); 
printf("%d\n", sizeof(*a)); 
printf("%d\n", sizeof(a + 1)); 
printf("%d\n", sizeof(a[1])); 
printf("%d\n", sizeof(&a));
printf("%d\n", sizeof(*&a)); 
printf("%d\n", sizeof(&a + 1)); 
printf("%d\n", sizeof(&a[0]));
printf("%d\n", sizeof(&a[0] + 1));

 

 

 char arr[] = { 'a','b','c','d','e','f' };
	printf("%d\n", sizeof(arr));
	printf("%d\n", sizeof(arr+0));
	printf("%d\n", sizeof(*arr));
	printf("%d\n", sizeof(arr[1]));
	printf("%d\n", sizeof(&arr));
	printf("%d\n", sizeof(&arr + 1));
	printf("%d\n", sizeof(&arr[0] + 1));
	printf("%d\n", strlen(arr));
	printf("%d\n", strlen(arr + 0));
	printf("%d\n", strlen(*arr));
	printf("%d\n", strlen(arr[1]));
	printf("%d\n", strlen(&arr));
	printf("%d\n", strlen(&arr + 1));
	printf("%d\n", strlen(&arr[0] + 1));

 

指標和陣列面試解析(2)  https://blog.csdn.net/qq_271334644/article/details/84818701