Does Posix supply format string macros for printf/scanf?

前端 未结 2 1108
小蘑菇
小蘑菇 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:49

    The sfio package (part of AT&T Labs' open source AST software) has functions analogous to printf and scanf which let you specify the size of the numeric value (typically using sizeof()) as an additional parameter. Some examples:

    sfprintf(sfstdout, "%I*d", sizeof(intval), intval);
    sfscanf(sfstdin, "%I*f", sizeof(fltval), &fltval);
    

    USENIX paper: Extended Data Formatting Using Sfio .

提交回复
热议问题