标签:
// strlen与sizeof对数组和指针的求法
#include <stdio.h>
#include <string.h>
int main()
{
char *pcColor = "12345678";
char acColor[] = "12345678";
printf("%d\n", strlen(pcColor));//8 求字符串的大小
printf("%d\n", strlen(acColor));//8 求字符数组的大小
printf("%d\n", sizeof(pcColor)); //4 求pcColor指针的大小
printf("%d\n", sizeof(acColor));//9 求字符数组的大小,包括\0
return 0;
}
标签:
原文地址:http://blog.csdn.net/zhaoyaqian552/article/details/45584995