189 8069 5689

sizeof直接常量时候c/c++解释不同-创新互联

见代码:

成都创新互联-专业网站定制、快速模板网站建设、高性价比安居网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式安居网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖安居地区。费用合理售后完善,十多年实体公司更值得信赖。
#include#includeint main(void){//直接常量时候c/c++解释不同
	printf("%lu\n",sizeof 'a');//4(c) 1(c++)
	//之后的c/c++解释相同
	printf("%lu\n",sizeof "a");//2
	
	char a = 'a';
	const char *pa = "a";
	printf("%lu\n",sizeof a);//1
	printf("%lu\n",sizeof pa);//8
	
	printf("%lu\n",sizeof 100);//4
	printf("%lu\n",sizeof 100L);//8
	return EXIT_SUCCESS;
}

编译环境:
root@DESKTOP-BE054DB:/mnt/i# gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
Copyright © 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

root@DESKTOP-BE054DB:/mnt/i# g++ --version
g++ (Ubuntu 9.4.0-1ubuntu1~20.04) 9.4.0
Copyright © 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

你是否还在寻找稳定的海外服务器提供商?创新互联www.cdcxhl.cn海外机房具备T级流量清洗系统配攻击溯源,准确流量调度确保服务器高可用性,企业级服务器适合批量采购,新人活动首月15元起,快前往官网查看详情吧


网站栏目:sizeof直接常量时候c/c++解释不同-创新互联
新闻来源:http://cdxtjz.cn/article/psooj.html

其他资讯