This article details very tiny feature of C Programming language that is string literal concatenation. As we know constant string(string literal) are put in double quote in C. If there are two string placed side by side, with or without white-space then they are concatenated. Let us explore it by an example.
#include <stdio.h> int main() { char *p = "Hello " "World"; printf("p is %s\n", p); return 0; }
p is Hello World
In the above program there are two string constants Hello
and World
which are placed side by side. Then the C concatenates them ignoring the white-space if any between the string constant. This comes in very handy if there is long strings that need to spread across several lines.
Links
- Next Article - C Programming #81: Token Concatenation
- Previous Article - C Programming #79: strstr implementation
- All Article - C Programming
No comments :
Post a Comment