Ad space (banner)
๐Ÿ”งC Lessons
Lesson 46 / 68

Multi-Line Strings (Adjacent String Literal Concatenation)

This lesson covers concatenating adjacent string literals in C, so you can build a readable message. It's for anyone searching "C multi-line string usage."

In C, multiple adjacent string literals are automatically concatenated into one string at compile time. Using this feature, you can split code across multiple lines while it's still treated as a single string at runtime.

The example lines up three string literals, each on its own line, as an argument to printf(). The compiler automatically joins these into one string, letting you format a long message readably.

A common early mistake is not realizing this concatenation happens at compile time, not runtime. It can't be used to dynamically build a string that includes variables โ€” it only works between fixed string literals.

In real projects, this feature is used to write a long SQL statement or message template readably within the code.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run C directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)