Does Posix supply format string macros for printf/scanf?

前端 未结 2 1100
小蘑菇
小蘑菇 2021-02-14 18:31

The printf and scanf families of functions in C consume a handful of primitive format specifiers that correspond to the fundamental data types –

2条回答
  •  无人及你
    2021-02-14 18:58

    Posix guarantees that sys/types.h values are an "arithmetic type of appropriate length" with a few others as being further specified as unsigned or signed 'extended length'. The only standards-acceptable way to output those would be to transfer it via cast in the largest appropriate language type (u)intmax_t and then output that.

    Inputting them would be more dangerous (i.e., not possible in a standards-compliant fashion) as it would be difficult to guarantee your conversion to the base type didn't overflow something.

提交回复
热议问题