two strings separated by blank being concatenated automatically

前端 未结 3 1092
醉话见心
醉话见心 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.

提交回复
热议问题