字符串字面常量只能初始化相应类型字符数组
char str[] = "abc"; // str has type char[4] and holds 'a', 'b', 'c', '\0'
wchar_t wstr[4] = L"猫"; // str has type wchar_t[4] and holds L'猫', '\0', '\0', '\0'
char str[3] = "abc"; // str has type char[3] and holds 'a', 'b', 'c'
所有类型的数组(包括字符数组)都可以用花括号来初始化
int x[] = {1,2,3}; // x has type int[3] and holds 1,2,3
int y[5] = {1,2,3}; // y has type int[5] and holds 1,2,3,0,0
int z[3] = {0}; // z has type int[3] and holds all zeroes
https://en.cppreference.com/w/c/language/array_initialization
你就不能写出来吗,问个问题也要偷懒。
声明数组必须用大括号,字符串才可以用双引号