#include<stdio.h>
#include<string.h>
int main(){
char a[]={'a','b','c','d','\0'};
printf("%lu------%lu\n",sizeof a,strlen(a));
//strlen的用法是计算字符串的长度但是遇到\0 会结束计算
char b[]={'a','b','\0','c','d','\0'};
printf("%lu-----------%lu\n",sizeof b,strlen(b));
//sizeof的用法是计算占用内存的字节数不会遇到\0停止
return 0;
} |
|