String concatenation using preprocessor

前端 未结 4 1836
南方客
南方客 2020-12-11 00:33

is it possible to concatenate strings during preprocessing?

I found this example

#define H \"Hello \"
#define W \"World!\"
#define HW H W

printf(HW)         


        
4条回答
  •  无人及你
    2020-12-11 00:44

    Concatenation of adjacent string litterals isn't a feature of the preprocessor, it is a feature of the core languages (both C and C++). You could write:

    printf("Hello "
           " world\n");
    

提交回复
热议问题