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

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

執行環境 VS   執行系統32

 char arr[] = "abcdef";
   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));

 



   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("%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));
  

 

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