Please explain the output! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
15th Sep 2019, 3:19 PM
Camille
3 Answers
+ 6
#define PRINTF "%s, Bazinga ! \n" printf(PRINTF,PRINTF); Above statement is same as printf("%s, Bazinga ! \n", "%s, Bazinga ! \n"); Format specifier is used twice i.e %s First statement will processed like this, "%s Bazinga ! " ---> Note: ending double quote is on new line Now, %s will be replaced by the string "%s, Bazinga ! \n" So final output is like : "%s, Bazinga ! ,Bazinga ! " Why %s is not replaced again? Well that's because now it is part of string.
15th Sep 2019, 4:34 PM
blACk sh4d0w
blACk sh4d0w - avatar
+ 4
nAutAxH AhmAd Thank you so much ! Very explanatory answer. Helped me understand. And thanks for the double quote mention too :)
15th Sep 2019, 4:51 PM
Camille
+ 3
~ swim ~ Thanks a ton ! Thanks for the brief overview of theory that I highly needed . You explain it so well. I really appreciate the example case as well. Best part!
15th Sep 2019, 4:49 PM
Camille