在 c 语句中计算令牌 [英] Calculating tokens in c statement
问题描述
以下 C 语句中的标记数.
The number of tokens in the following C statement.
printf("i = %d, &i = %x", i, &i);
我认为这里有 12 个令牌.但我的回答是错误的.
I think there are 12 tokens here. But my answer is wrong.
谁能告诉我如何在上面的 C 语句中找到标记?
Can anybody tell me how to find the tokens in the above C statement?
PS:我知道标记是编译器不会分解为组件元素的源程序文本.
PS: I know that a token is source-program text that the compiler does not break down into component elements.
推荐答案
据我了解的 C 代码解析,token 是(共 10 个):
As far as I understand C code parsing, the tokens are (10 in total):
printf
(
"i = %d, &i = %x"
,
i
,
&
i
)
;
我不计算空格,它通常没有意义,仅用作其他标记之间的分隔符,而且我不会将字符串文字分解为多个部分,因为它是其自身的一个完整实体.
I don't count white space, it's generally meaningless and only serves as a separator between other tokens, and I don't break down the string literal into pieces, because it's an integral entity of its own.
这篇关于在 c 语句中计算令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!