定宽整数类型

定宽整数类型

(stdint.h) - C++ Reference (cplusplus.com)

Fixed width integer types (since C++11) - cppreference.com

定宽整数类型,是确定大小的整数类型。
定宽整数类型与基础类型相比,能更清楚地描述类型的性质。例如,int类型可能是16位、32位或64位,但是int32_t类型一定是32位。

#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>

int main()
{
	uint32_t sale = 0;
	scanf("%" SCNu32, &sale);
	printf("sale = %" PRIu32 "\n", sale);
	printf("UINT32_MAX = %#" PRIx32 "\n", UINT32_MAX);
	return 0;
}


posted @ 2021-07-14 21:09  ltimaginea  阅读(140)  评论(0编辑  收藏  举报