qfedu-c-level/day6/d13.c

18 lines
586 B
C
Raw Permalink Normal View History

2023-07-10 17:46:22 +08:00
#include <stdio.h>
#include <string.h>
int main()
{
char ask_name[32] = "Jack"; // 结果是 "Jack\0"
printf("%s\n", ask_name);
// sizeof() 统计变量或数组实际分配的内存空间大小,单位是字节
printf("ask_name size is %ldB\n", sizeof(ask_name));
// strlen() 函数统计有效的字符个数,不包括 '\0' (遇到第一个 '\0' 就停止统计 )
printf("ask_name char len is %ld\n", strlen(ask_name));
char q_what1[128] = "hi,xiao hua\0,love you!";
printf("%s\n", q_what1);
printf("%ld \n", strlen(q_what1));
return 0;
}