如果`char`转换为`int`,为什么``%c'`存在于`printf`中?

Pau*_*nta 5 c printf variadic-functions

在C你有"%c""%f"的格式标志printf-和scanf式的功能.这两个功能的使用可变长度参数...,它总是转换floatsdoublescharsints.

我的问题是,如果这种转换发生,为什么做独立的标志charfloat存在吗?为什么不只使用相同的标志intdouble

相关问题:
为什么scanf()需要"%lf"用于双打,当printf()只用"%f"时可以吗?

Luc*_*ore 10

因为打印出来的方式不同.

printf("%d \n",100); //prints 100
printf("%c \n",100); //prints d - the ascii character represented by 100
Run Code Online (Sandbox Code Playgroud)

  • @PaulManta:`%f`格式化标志需要一个`double`参数. (3认同)