#include <stdio.h>
#include <string.h>

int main() {
    // 字符串数组：每个元素是char*类型
    char *strArr[] = {"apple", "banana", "cherry", "date", "elderberry"};
    int len = sizeof(strArr) / sizeof(strArr[0]);  // 数组长度
    char **p = strArr;  // 二级指针p指向字符串数组首元素
    int maxLen = 0;
    char *longestStr;

    printf("字符串数组元素：\n");
    for (int i = 0; i < len; i++) {
        printf("%s\n", *(p + i));  // 二级指针访问第i个字符串

        // 统计最长字符串
        int currentLen = strlen(*(p + i));
        if (currentLen > maxLen) {
            maxLen = currentLen;
            longestStr = *(p + i);
        }
    }

    printf("最长字符串是：%s，长度：%d\n", longestStr, maxLen);

    return 0;
}
