Returning const char*/ std::string.c_str()
I have a function in a program that's something like the following. When I try to output what it returns, however, it doesn't print anything on the screen. The following isn't exactly what I'm using, but it gets the point across.
Alternately, if I replace the contents of the function with:
const char* getcolor(bool top)
if (top == 1)
color_convert << 160;
color_convert << 200;
string1 = color_convert.str();
then it will return something that I can print out. Does anyone know why this is? I'm guessing it's something to do with pointers- like in the first function, the pointer to the string is empty after it's returned or something? It's weird though because both functions use pointers to stuff. I don't see why one should be empty and the other not.
const char* c_string1 = "160";