Compilation of string literals

后端 未结 5 1222
臣服心动
臣服心动 2021-01-13 16:32

Why can two string literals separated by a space, tab or \"\\n\" be compiled without an error?

int main()
{
   char * a = \"aaaa\"  \"bbbb\";
} 
5条回答
  •  走了就别回头了
    2021-01-13 17:25

    String literals placed side-by-side are concatenated at translation phase 6 (after the preprocessor). That is, "Hello," " world!" yields the (single) string "Hello, world!". If the two strings have the same encoding prefix (or neither has one), the resulting string will have the same encoding prefix (or no prefix).

    (source)

提交回复
热议问题