I try to convert uint64_t to const char *. But I find If I use
const char *sz2 = std::to_string(channel_id2).c_str();, it print nothing.
when I use string to take std::to_string(channel_id2)'s result and convert the string to const char *, it can print the infomation normally. Then I make other experiments.



This is fine:
However, when you do:
The order of operations is:
std::to_string, which generates a temporary string object.c_str()to get a pointer to the temporary string contentsThe result is that sz2 is pointing at nothing valid, and so you get nonsense results printed out
Or to translate your one line of code across multiple lines, this is what is happening: