您的位置:首页 > 编程语言 > C语言/C++

【c语言】strlen与sizeof对数组和指针的求法

2015-05-08 21:07 656 查看
// 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;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: