compiler construction - Number of C Tokens -
what number of tokens in following c statement?
printf("i = %d, &i = %x", i, &i); the answer 10, please explain why is?
i have searched http://www.c4learn.com/c-programming/c-tokens-keywords-identifiers/ , https://msdn.microsoft.com/en-us/library/c6sb2c6b.aspx , opinion 9.
printf - 1
() - 2
"i = %d, &i = %x" - 1
, - 2
i,&i - 2
; - 1
total = 1 + 2 + 1 + 2 + 2 + 1 = 9
i totally new c please me
just put space between nothing changes in semantics:
printf ( "i = %d, &i = %x" , , & ) ; then count parts between spaces: 10 tokens! note tokens "words", dots, etc. in natural language. have nothing semantics (which part of parser).
note not particularily related c (except tokens valid), general processing language. read compiler construction. there books along (e.g. n. wirth's classic available free download)
Comments
Post a Comment