MMH,你是谁PRIu64? [英] Mmh, who are you PRIu64?

查看:220
本文介绍了MMH,你是谁PRIu64?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的C,我面临着:

I am new to C and I am confronted with:

#include <stdio.h>
#include <inttypes.h>

int main(void)
{
    uint64_t foo = 10;
    printf("foo is equal to %" PRIu64 "!\n", foo);

    return 0;
}

和它的作品!我不明白为什么?有人可以帮我这个?
非常感谢!

And it works! I don't understand why? Can somebody help me about this? Thanks a lot! torr

推荐答案

PRIu64 是一个格式说明,在C99,印刷 uint64_t中介绍其中 uint64_t中是(来自链接参考页):

PRIu64 is a format specifier, introduced in C99, for printing uint64_t, where uint64_t is (from linked reference page):

分别为64位无符号整型与宽度...
  (前提只有在执行直接支持的类型)

unsigned integer type with width of ... 64 bits respectively (provided only if the implementation directly supports the type)

PRIu64 是一个字符串(文字),例如以下内容:

PRIu64 is a string (literal), for example the following:

printf("%s\n", PRIu64);

打印 LLU 我的机器上。相邻字符串文字并置,从截面的 6.4.5字符串字面的的C99标准:

prints llu on my machine. Adjacent string literals are concatenated, from section 6.4.5 String literals of the C99 standard:

在翻译阶段6,按相邻字符和宽字符串文字标记任意顺序指定的多字节字符序列连接成一个单一的多字节字符序列。如果任何令牌都是宽字符串文字标记,产生的多字节字符序列视为一个宽字符串文字;否则,将被视为字符串文字。

In translation phase 6, the multibyte character sequences specified by any sequence of adjacent character and wide string literal tokens are concatenated into a single multibyte character sequence. If any of the tokens are wide string literal tokens, the resulting multibyte character sequence is treated as a wide string literal; otherwise, it is treated as a character string literal.

这意味着:

printf("foo is equal to %" PRIu64 "!\n", foo);

(我的机器上)是一样的:

(on my machine) is the same as:

printf("foo is equal to %llu!\n", foo);

请参阅 http://ideone.com/jFvKR9

这篇关于MMH,你是谁PRIu64?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆