Is it guranteed that the string literals are stored adjacent in the memory?
Therefore does the below necessarily get an output hellohello
printf(3 + "%d");
printf("hello");
No, string literals are stored wherever your compiler fancies. The fact that you declared two of them in consecutive lines is irrelevant. You can make no assumptions about where the compiler will store them.
The compiler can do all sorts of things. For example, if you write the following code
printf("hello");
printf("hello");
then the compiler is perfectly at liberty to create only a single literal. Or not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With