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");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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
then the compiler is perfectly at liberty to create only a single literal. Or not.