two strings separated by blank being concatenated automatically

前端 未结 3 1068
醉话见心
醉话见心 2021-01-19 03:13

I just found something very interesting which was introduced by my typo. Here\'s a sample of very easy code script:

printf(\"A\" \"B\");

Th

相关标签:
3条回答
  • 2021-01-19 03:41

    As a part of the C standard, string literals that are next to one another are concatenated:

    For C (quoting C99, but C11 has something similar in 6.4.5p5):

    (C99, 6.4.5p5) "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."

    C++ has a similar standard.

    0 讨论(0)
  • 2021-01-19 03:47

    This is string concatenation, part of C standard. Any two or more consecutive string literals are combined into one.

    0 讨论(0)
  • 2021-01-19 03:55

    This is standard behaviour and can be very useful when splitting a very long string constant over multiple lines.

    0 讨论(0)
提交回复
热议问题