char字符和字符串

cooolr 于 2021-11-10 发布
#include <stdio.h>

int main() {
    // 字符
    char text = 'h';
    printf("%c\n", text);
    // 字符数组1
    char text_list1[] = {'h','e','l','l','o'};
    printf("%s\n", text_list1);
    // 字符数组2
    char text_list2[] = "hello";
    printf("%s\n", text_list2);
    // 指针字符数组/字符串
    char *text_list3 = "hello";
    printf("%s\n", text_list3);
    // 指针字符串数组
    char *text_list4[] = {"hello","world"};
    printf("%s\n", text_list4[0]);
    return 1;
}