4 ms·
From the article: """ It's a little-known feature of C that if you put two string literals next to each other in the source code, they get concatenated: c
by davvid 16y ago
From the article:
"""
It's a little-known feature of C that if you put two string literals next to each other in the source code, they get concatenated:
char *helloworld = "hello, " "world!";
"""
That's a good tip that actually works in other languages too. It helps in Python, for example, when creating long strings. Wrapping parentheses around the string and using the quote-continuation rule makes it nice and easy to read.
For example:
foo = ('hello world this is '
'a long string')
is better than:
foo = 'hello world this is ' + \
'a long string'
...for two reasons. It avoids string concatenation (the "+" operator) and it avoids the backslash.