char c1[] = "sdfa";//系统自动添加结束字符 \0
char c2[] = {‘1‘,‘2‘,‘3‘};//这样赋值的话,要自己加上结束字符 \0
printf("%s\t %s\n",c1,c2);
printf("%lu\t %lu\n",strlen(c1),sizeof(c2));//strlen获得字符串长度,不包括\0
时间: 2024-10-27 17:53:30
char c1[] = "sdfa";//系统自动添加结束字符 \0
char c2[] = {‘1‘,‘2‘,‘3‘};//这样赋值的话,要自己加上结束字符 \0
printf("%s\t %s\n",c1,c2);
printf("%lu\t %lu\n",strlen(c1),sizeof(c2));//strlen获得字符串长度,不包括\0