今天偶然间看到这个头文件inttypes,好奇有什么用,去找度娘玩了一波,发现这头文件挺有意思的。

  这个头文件适配于C99标准,它提供整数输入的各种进制转换的宏,这是在Ubuntu上扣下来的代码(windows里我没找到放在哪)嗯~ o(* ̄▽ ̄*)o我拿VScode找到了……所以划掉

  不完整的

Ubuntu:

 //这里应该是10进制的宏
/* Decimal notation. */
# define PRId8 "d"
# define PRId16 "d"
# define PRId32 "d"
# define PRId64 __PRI64_PREFIX "d" # define PRIdLEAST8 "d"
# define PRIdLEAST16 "d"
# define PRIdLEAST32 "d"
# define PRIdLEAST64 __PRI64_PREFIX "d" # define PRIdFAST8 "d"
# define PRIdFAST16 __PRIPTR_PREFIX "d"
# define PRIdFAST32 __PRIPTR_PREFIX "d"
# define PRIdFAST64 __PRI64_PREFIX "d" # define PRIi8 "i"
# define PRIi16 "i"
# define PRIi32 "i"
# define PRIi64 __PRI64_PREFIX "i" # define PRIiLEAST8 "i"
# define PRIiLEAST16 "i"
# define PRIiLEAST32 "i"
# define PRIiLEAST64 __PRI64_PREFIX "i" # define PRIiFAST8 "i"
# define PRIiFAST16 __PRIPTR_PREFIX "i"
# define PRIiFAST32 __PRIPTR_PREFIX "i"
# define PRIiFAST64 __PRI64_PREFIX "i" //感觉这里是8进制的宏
/* Octal notation. */
# define PRIo8 "o"
# define PRIo16 "o"
# define PRIo32 "o"
# define PRIo64 __PRI64_PREFIX "o" # define PRIoLEAST8 "o"
# define PRIoLEAST16 "o"
# define PRIoLEAST32 "o"
# define PRIoLEAST64 __PRI64_PREFIX "o" # define PRIoFAST8 "o"
# define PRIoFAST16 __PRIPTR_PREFIX "o"
# define PRIoFAST32 __PRIPTR_PREFIX "o"
# define PRIoFAST64 __PRI64_PREFIX "o" //这里因该是无符号的宏
/* Unsigned integers. */
# define PRIu8 "u"
# define PRIu16 "u"
# define PRIu32 "u"
# define PRIu64 __PRI64_PREFIX "u" # define PRIuLEAST8 "u"
# define PRIuLEAST16 "u"
# define PRIuLEAST32 "u"
# define PRIuLEAST64 __PRI64_PREFIX "u" # define PRIuFAST8 "u"
# define PRIuFAST16 __PRIPTR_PREFIX "u"
# define PRIuFAST32 __PRIPTR_PREFIX "u"
# define PRIuFAST64 __PRI64_PREFIX "u" //这里因该是小写16进制
/* lowercase hexadecimal notation. */
# define PRIx8 "x"
# define PRIx16 "x"
# define PRIx32 "x"
# define PRIx64 __PRI64_PREFIX "x" # define PRIxLEAST8 "x"
# define PRIxLEAST16 "x"
# define PRIxLEAST32 "x"
# define PRIxLEAST64 __PRI64_PREFIX "x" # define PRIxFAST8 "x"
# define PRIxFAST16 __PRIPTR_PREFIX "x"
# define PRIxFAST32 __PRIPTR_PREFIX "x"
# define PRIxFAST64 __PRI64_PREFIX "x" //这里因该是大写16进制
/* UPPERCASE hexadecimal notation. */
# define PRIX8 "X"
# define PRIX16 "X"
# define PRIX32 "X"
# define PRIX64 __PRI64_PREFIX "X" # define PRIXLEAST8 "X"
# define PRIXLEAST16 "X"
# define PRIXLEAST32 "X"
# define PRIXLEAST64 __PRI64_PREFIX "X" # define PRIXFAST8 "X"
# define PRIXFAST16 __PRIPTR_PREFIX "X"
# define PRIXFAST32 __PRIPTR_PREFIX "X"
# define PRIXFAST64 __PRI64_PREFIX "X"

Windows:

/* fprintf macros for signed types */
#define PRId8 "d"
#define PRId16 "d"
#define PRId32 "d"
#define PRId64 "I64d" #define PRIdLEAST8 "d"
#define PRIdLEAST16 "d"
#define PRIdLEAST32 "d"
#define PRIdLEAST64 "I64d" #define PRIdFAST8 "d"
#define PRIdFAST16 "d"
#define PRIdFAST32 "d"
#define PRIdFAST64 "I64d" #define PRIdMAX "I64d"
#define PRIdPTR "d" #define PRIi8 "i"
#define PRIi16 "i"
#define PRIi32 "i"
#define PRIi64 "I64i" #define PRIiLEAST8 "i"
#define PRIiLEAST16 "i"
#define PRIiLEAST32 "i"
#define PRIiLEAST64 "I64i" #define PRIiFAST8 "i"
#define PRIiFAST16 "i"
#define PRIiFAST32 "i"
#define PRIiFAST64 "I64i" #define PRIiMAX "I64i"
#define PRIiPTR "i" #define PRIo8 "o"
#define PRIo16 "o"
#define PRIo32 "o"
#define PRIo64 "I64o" #define PRIoLEAST8 "o"
#define PRIoLEAST16 "o"
#define PRIoLEAST32 "o"
#define PRIoLEAST64 "I64o" #define PRIoFAST8 "o"
#define PRIoFAST16 "o"
#define PRIoFAST32 "o"
#define PRIoFAST64 "I64o" #define PRIoMAX "I64o" #define PRIoPTR "o" /* fprintf macros for unsigned types */
#define PRIu8 "u"
#define PRIu16 "u"
#define PRIu32 "u"
#define PRIu64 "I64u" #define PRIuLEAST8 "u"
#define PRIuLEAST16 "u"
#define PRIuLEAST32 "u"
#define PRIuLEAST64 "I64u" #define PRIuFAST8 "u"
#define PRIuFAST16 "u"
#define PRIuFAST32 "u"
#define PRIuFAST64 "I64u" #define PRIuMAX "I64u"
#define PRIuPTR "u" #define PRIx8 "x"
#define PRIx16 "x"
#define PRIx32 "x"
#define PRIx64 "I64x" #define PRIxLEAST8 "x"
#define PRIxLEAST16 "x"
#define PRIxLEAST32 "x"
#define PRIxLEAST64 "I64x" #define PRIxFAST8 "x"
#define PRIxFAST16 "x"
#define PRIxFAST32 "x"
#define PRIxFAST64 "I64x" #define PRIxMAX "I64x"
#define PRIxPTR "x" #define PRIX8 "X"
#define PRIX16 "X"
#define PRIX32 "X"
#define PRIX64 "I64X" #define PRIXLEAST8 "X"
#define PRIXLEAST16 "X"
#define PRIXLEAST32 "X"
#define PRIXLEAST64 "I64X" #define PRIXFAST8 "X"
#define PRIXFAST16 "X"
#define PRIXFAST32 "X"
#define PRIXFAST64 "I64X" #define PRIXMAX "I64X"
#define PRIXPTR "X" /*
* fscanf macros for signed int types
* NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t
* (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have
* no length identifiers
*/ #define SCNd16 "hd"
#define SCNd32 "d"
#define SCNd64 "I64d" #define SCNdLEAST16 "hd"
#define SCNdLEAST32 "d"
#define SCNdLEAST64 "I64d" #define SCNdFAST16 "hd"
#define SCNdFAST32 "d"
#define SCNdFAST64 "I64d" #define SCNdMAX "I64d"
#define SCNdPTR "d" #define SCNi16 "hi"
#define SCNi32 "i"
#define SCNi64 "I64i" #define SCNiLEAST16 "hi"
#define SCNiLEAST32 "i"
#define SCNiLEAST64 "I64i" #define SCNiFAST16 "hi"
#define SCNiFAST32 "i"
#define SCNiFAST64 "I64i" #define SCNiMAX "I64i"
#define SCNiPTR "i" #define SCNo16 "ho"
#define SCNo32 "o"
#define SCNo64 "I64o" #define SCNoLEAST16 "ho"
#define SCNoLEAST32 "o"
#define SCNoLEAST64 "I64o" #define SCNoFAST16 "ho"
#define SCNoFAST32 "o"
#define SCNoFAST64 "I64o" #define SCNoMAX "I64o"
#define SCNoPTR "o" #define SCNx16 "hx"
#define SCNx32 "x"
#define SCNx64 "I64x" #define SCNxLEAST16 "hx"
#define SCNxLEAST32 "x"
#define SCNxLEAST64 "I64x" #define SCNxFAST16 "hx"
#define SCNxFAST32 "x"
#define SCNxFAST64 "I64x" #define SCNxMAX "I64x"
#define SCNxPTR "x" /* fscanf macros for unsigned int types */
//感觉这里是无符号
#define SCNu16 "hu"
#define SCNu32 "u"
#define SCNu64 "I64u" #define SCNuLEAST16 "hu"
#define SCNuLEAST32 "u"
#define SCNuLEAST64 "I64u" #define SCNuFAST16 "hu"
#define SCNuFAST32 "u"
#define SCNuFAST64 "I64u" #define SCNuMAX "I64u"
#define SCNuPTR "u"

  我感觉gcc这个源码没有Ubuntu哪个那么容易看懂,管他呢……用法是一样的

百度上的例子:

  PRIi8、PRIu8、PRIo8以及PRIx8,其中i为有符号,u为无符号,o为8进制以及x为16进制。

百度上的代码:

#include <stdio.h>
#include <inttypes.h> int main() {
int a = ;
printf("a=%"PRIu64"\n", a);
return ;
}

  输出是啥我不太明白,感觉像是按位把int 拓展成了long long 导致出现了一个特别奇怪的数

我做了其他的测试

    int a = ;
printf("a=%"PRx8"\n", a);

输出的是 f

    int a = 0xff;
printf("a=%"PRu8"\n", a);

输出的是255

  嘿嘿,真是个进制转换的神器,不过好像没有二进制,而且只有常用的8和16,其他的还得自己写,这个库里还有其他功能,我先研究研究,日后再更新。(现在主要是防止自己忘记)

学习不易,诸君共勉!

C语言拾遗——inttypes.h的更多相关文章

  1. C语言拾遗——strtok

    C语言拾遗——strtok 今天刷PAT的时候用到了这个strtok函数,顺手就记录一下 strtok函数包含于头文件string.h 语法:char *strtok( char *str1, con ...

  2. 使用ACE遇到无法打开包括文件:“inttypes.h”的解决方案

    本来想使用ACE_Get_Opt类来做一个命令行解析的功能,但是当项目中配置好了ACE库的路径后,编译时遇到"无法打开包括文件: inttypes.h : No such file or d ...

  3. ffmpeg遇到inttypes.h和UINT64_C

    http://blog.csdn.net/cll131421/article/details/7763657 编译过程:错误一:无法打开包括文件:“inttypes.h”: No such file ...

  4. ffmpeg “inttypes.h”: No such file or directory

    编译过程:错误一:无法打开包括文件:“inttypes.h”: No such file or directory解决方法:删除之,并在其之前添加如下代码: #if defined(WIN32) &a ...

  5. C语言拾遗(一)

    越来越体会到C语言的重要性,不管是在计算机底层的理解上,还是在算法数据结构上,所以遂决定重新拾起C语言,不定期更新一些知识点. 推荐博客:http://blog.csdn.net/itcastcpp ...

  6. C语言.c和.h

    简单的说其实要理解C文件与头文件(即.h)有什么不同之处,首先需要弄明白编译器的工作过程,一般说来编译器会做以下几个过程:       1.预处理阶段 2.词法与语法分析阶段 3.编译阶段,首先编译成 ...

  7. C 语言项目中.h文件和.c文件的关系

    http://blog.csdn.net/xingkong_678/article/details/38639847 关于两者以前的关系,要从N年以前说起了~ long long ago,once a ...

  8. windows+vs2017+C语言 引入mysql.h对MYSQL数据库的操作

    mysql.h文件用作VS开发用,用来连接数据库.没有mysql.h文件,就无法调用mysql的东西 也无法用C语言对MYSQL操作. 一般安装了mysql之后,这个文件就在mysql目录的inclu ...

  9. C语言拾遗

    1. 没C++那么恶心的const C语言中的const修饰符用于修饰一个变量是const属性的.被C语言的const修饰的变量具有只读属性,并且不能被修改. const修饰的变量 != 常量,con ...

随机推荐

  1. 使用U盘安装Linux最美桌面发行版Elementary OS 及常用开发环境配置(JDK,Redis,MySQL,Docker,IDEA,STS)

    前言 假期在家无聊,刚好把六年前的一台笔记本电脑利用起来,原来电脑虽然说配置说不上古董机器,但是运行win系统感觉还是不流畅,所幸给换成Linux桌面版系统,在网上查阅了很多,Linux桌面系统要么推 ...

  2. VUE.JS和小程序的共通之处

    我是先学习的小程序开发,之后才了解到vue.js.也是一直没有时间去看相关vue.js的知识和内容.现在回顾起来,小程序和vue.js都是前端的内容. 例如小程序中的目录结构物page+app.js+ ...

  3. 如何在linux中解压.rar文件

    在liunx下原本是不支持rar文件的,需要安装liunx下的winrar版本 步骤: 1.http://www.rarsoft.com/rar/rarlinux-4.0.1.tar.gz 从这个网址 ...

  4. eot文件

    *.eot文件 是一种压缩字库,目的是解决在网页中嵌入特殊字体的难题2.在网页中嵌入的字体只能是 OpenType 类型,其他类型的字体只有转换成 OpenType 类型(eot格式)的字体才能在网页 ...

  5. SciPy 插值

    章节 SciPy 介绍 SciPy 安装 SciPy 基础功能 SciPy 特殊函数 SciPy k均值聚类 SciPy 常量 SciPy fftpack(傅里叶变换) SciPy 积分 SciPy ...

  6. MQTT 协议学习:002- 通信报文的构成

    背景 之前工作中参与有关协议调试的时候,发现对于协议帧的解析是比较重要的. 参考:<MQTT协议 -- 消息报文格式>.<基于STM32实现MQTT>.<MQTT协议从服 ...

  7. 解决NLPIR汉语分词系统init failed问题

    今天第一次使用NLPIR汉语分词系统. 遇到的问题: 当点击时, 出现以下界面 看了博客https://blog.csdn.net/yuyanyanyanyanyu/article/details/5 ...

  8. 部署 Prometheus Operator【转】

    本节在实践时使用的是 Prometheus Operator 版本 v0.14.0.由于项目开发迭代速度很快,部署方法可能会更新,必要时请参考官方文档. 下载最新源码 git clone https: ...

  9. 第3节 sqoop:6、sqoop的数据增量导入和数据导出

    增量导入 在实际工作当中,数据的导入,很多时候都是只需要导入增量数据即可,并不需要将表中的数据全部导入到hive或者hdfs当中去,肯定会出现重复的数据的状况,所以我们一般都是选用一些字段进行增量的导 ...

  10. KMP【模板】 && 洛谷 P3375

    题目传送门 解题思路: 首先说KMP的作用:对于两个字符串A,B(A.size() > B.size()),求B是否是A的一个字串或B在A里的位置或A里有几个B,说白了就是字符串匹配. 下面创设 ...