char s[10] = "Hello"; // 剩余全用0填充
char s[10] = {'H','e','l','l','o','\0'}; //和上面效果一样
char s[10] = {'H','e','l','l','o'}; // 和前面效果一样
char s[10] = {0} // 全部初始化为0
char s[10] = "Hello, world.\n"; // 超出部分丢弃,没有字符串结尾符
char s[] = "Hello, world.\n"; // sizeof = strlen + 1
上一篇
下一篇