I am looking for sample code for an API that I am going to start using. The following template confuses me a bit:
char* str; str = const_cast<char*>("Hello World"); printf("%s ", str);
(there is actually a huge case statement in which str is assigned in each case.)
Note that printf accepts const char* . Is there a reasonable purpose for this minimized transformation? The authors of this code apply many performance-oriented tricks elsewhere, but there is no explanation for what happens here.
My instinct is to change this code to:
const char* str; str = "Hello World"; printf("%s ", str);
Did I miss something?
source share