'No. of strings in format string specifier [duplicate]
I have seen this way of using combination of strings in printf and scanf statements.
int a;
printf("Printing" "using" "multiple" "strings" "%d", a);
// The above is just an example, some usage that I saw was for printing specific integer types like int_32
// uint32_t var; printf("Value is %" PRTu32, var);
I always thought that we could only use a single string as a format specifier. Like as written in the definition of printf function it seems format can point to only one string.
int printf ( const char * format, ... );
So out of curiosity I tried the following code and it ran successfully!
char arr[] = "Hello " "World";
printf("%s",arr); // Output - Hello World
Could anyone explain how this concatenation thing works and what is the correct way of doing it. Any help is appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|