#include <stdio.h>
#include <string.h>
int main() {
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));
printf("=============================\n");
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("=============================\n");
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));
printf("=============================\n");
char b[] = "abcdef";
printf("%d\n", sizeof(b));
printf("%d\n", sizeof(b + 0));
printf("%d\n", sizeof(*b));
printf("%d\n", sizeof(b[1]));
printf("%d\n", sizeof(&b));
printf("%d\n", sizeof(&b + 1));
printf("%d\n", sizeof(&b[0] + 1));
printf("=============================\n");
printf("%d\n", strlen(b));
printf("%d\n", strlen(b + 0));
printf("%d\n", strlen(*b));
printf("%d\n", strlen(b[1]));
printf("%d\n", strlen(&b));
printf("%d\n", strlen(&b + 1));
printf("%d\n", strlen(&b[0] + 1));
printf("=============================\n");
char *p = "abcdef";
printf("%d\n", sizeof(p));
printf("%d\n", sizeof(p + 1));
printf("%d\n", sizeof(*p));
printf("%d\n", sizeof(p[0]));
printf("%d\n", sizeof(&p));
printf("%d\n", sizeof(&p + 1));
printf("%d\n", sizeof(&p[0] + 1));
printf("=============================\n");
printf("%d\n", strlen(p));
printf("%d\n", strlen(p + 1));
printf("%d\n", strlen(*p));
printf("%d\n", strlen(p[0]));
printf("%d\n", strlen(&p));
printf("%d\n", strlen(&p + 1));
printf("%d\n", strlen(&p[0] + 1));
}
标签:char,arr,函数,---,65,printf,sizeof,strlen
From: https://www.cnblogs.com/gaodiyuanjin/p/18487013