问题
It's a familiar fact that in C you can write "a" "b"
and get "ab"
. This is discussed in the C11
standard:
In translation phase 6, the multibyte character sequences specified by any sequence of adjacent character and identically-prefixed string literal tokens are concatenated into a single multibyte character sequence.
The phrase "character and..." would seem to suggest you can get the same results by writing 'a' "b"
, but I've never come across that usage and GCC and the Microsoft compiler both reject it. Am I missing something?
回答1:
No, maybe we're getting a wrong meaning out of the statement made there.
Let me quote from C11
, chapter §5.1.1.2, Translation phases, paragraph 6,
- Adjacent string literal tokens are concatenated.
Here, we don't have any confusion between char
and string literals, it's clearly mentioned about string literals only.
来源:https://stackoverflow.com/questions/30664664/adjacent-character-and-string-literal-tokens