char数组长度
1.strlen:可得实际长度,以\0结尾
2.sizeof:得到数据声明长度
char test[6] ="hello";
printf("\ntest=%s",test);
printf("\nsizetest=%d",strlen(test));
printf("\nsizeAtest=%d",sizeof(test));
console打印:
test=hello
sizetest=5
sizeAtest=6
char testA[7] ="he\0llo";
printf("\ntestA=%s",testA);
printf("\nsizetestA=%d",strlen(testA));
printf("\nsizeAtestA=%d",sizeof(testA));
console打印
testA=he
sizetestA=2
sizeAtestA=7
int/uint类:
直接可以用sizeof / sizeof 0求得数组长度
uint8_t num[50];
memset(num,88,50);
printf("size1=%d",sizeof(num));
printf("size2=%d",sizeof(num)/sizeof(num[0]));
console打印
size1=50size2=50