首页 > 编程语言 > 详细

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

时间:2015-05-08 22:04:08      阅读:251      评论:0      收藏:0      [点我收藏+]
// 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;
}


技术分享

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

原文:http://blog.csdn.net/zhaoyaqian552/article/details/45584995

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!