c++standards

Why func("abc" "def"); compiles


just stumbled onto a miss in my code, a function was called like this

func("text1" "text2");

instead of

func("text1", "text2");

The thing is that it actually compiles and runs (MSVC 2008), the two strings are treated as one (ie a call to an overloaded func gets the input "text1text2").

Is this normal standard behaviour (ie. "abc" "def" == "abcdef") or isn't it ?


Solution

  • Yes, this is called string literal concatenation, and is a feature of the C and C++ compiler.