发布时间:2022-08-09 文章分类:编程知识 投稿人:赵颖 字号: 默认 | | 超大 打印

5
down vote

Your code aptly demonstrates Undefined Behavior. Note that in case of variadic arguments no type checking is done for parameters. This is when an explicit cast becomes necessary. In fact the following should therefore be used:

printf("lld=%lld, ld=%ld, u=%u\n",
    (unsignedlonglong)temp,
    (unsignedlong)temp,
    (unsignedint)temp);

As an aside remember the specifier for size_t is z. So:

printf("zd=%zd\n", temp);