meng-chen

导航

 

#include<stdio.h>

int main() {
char arr[] = { "hello world" };
char arr1[] = { 'h','e','l','l','o' };
char arr2[] = { 'h','e','l','l','o','\0'};
printf("%s\n", arr);//hello world
printf("%s\n", arr1);//hello烫烫烫烫烫烫烫烫烫烫烫烫烫蘦ello
printf("%s\n", arr2);//hello
printf("%d\n", strlen(arr));//11
printf("%d\n", strlen(arr1));//报错
printf("%d\n", strlen(arr2));//5
return 0;
}

 

//因为arr1数组中没有\0所有程序会一直查找直到找到\0后才会停下来

//所以会报错

posted on 2022-03-20 14:22  AAAAAATT  阅读(821)  评论(0)    收藏  举报