C语言-字符数组
示例
#include <stdio.h>
#include <string.h>
int main(){
// 字符数组的初始化
char str1[] = "abcdefgh";
char str2[] = {'a','b','c','d','e','f','g','h'};
// char str3[] = {"a","b","c","d"}; // 错误的,是单引号
char str4[100] = {0};
// 求字符串的长度
int length_str1 = strlen(str1);
printf("length_str1 = %d\n",length_str1);
//求数组内元素个数
int length_str2 = sizeof(str2) / sizeof(str2[0]);
printf("length_str2 = %d\n",length_str2);
return 0;
}