CLearn/Chapter_3/3_6_altnames.c

26 lines
877 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* 本文件主要讲述可移植类型,这些类型引入了两个头文件以
确保 C 语言类型在各个系统中功能相同,定义了一批新的类型
比如如果要求一个数精确有32位
int32_t
或者要求一个数在可以容纳8位的情况下使用一个最小的类型
int_least8_t
或者如果你需要一个数容量尽可能大C99
intmax_t / uintmax_t
打印时,它们也提供了一些类似的例子。*/
#include <stdio.h>
#include <inttypes.h>
int main(void)
{
int32_t me32;
me32 = 45933945;
printf("First, assume int32_t is int: ");
printf("me32 = %d\n",me32);
printf("Next, let's not make any assumptions.\n");
printf("Instead, use a\"macro\" from inttypes.h: ");
printf("me32 = %"PRId32" \n",me32);
// 等价于下面这条语句:
printf("me32 = %""d"" \n",me32);
return 0;
}