I'm working on a software using a home-made report library which takes only (const char *) type as an argument :
ReportInfo(const char* information); ReportError(const char* error); [...] As I'm trying to report value of integers, I'd like to get a representation of those integers in a const char* type. I can do it that way :
int value = 42; string temp_value = to_string(value); const char *final_value= temp_value.c_str(); ReportInfo(final_value); It would be great if I could do it without instancing the temp_value. I tried this :
int value = 42; const char* final_value = to_string(value).c_str(); ReportInfo(final_value); but final_value is equal to '\0' in that case.
Any idea how to do it ?
temp_value? :-)final_valueis '\0'. It doesn't make sense to me.