S
sadegh
I wrote a function to convert any type to string:
template <typename T>
std::string toStr(const T &thing) {
std:
stringstream outStr;
outStr << thing;
return outStr.str();
}
the above function works properly. I also wrote another function to
convert any type to const char* but it doesent work properly
template <typename T>
const char* toCStr(const T &thing) {
std:
stringstream outStr;
outStr << thing;
std::string Str=outStr.str();
return Str.c_str();
}
Does any body know what is its problem?
Thanks
template <typename T>
std::string toStr(const T &thing) {
std:
outStr << thing;
return outStr.str();
}
the above function works properly. I also wrote another function to
convert any type to const char* but it doesent work properly
template <typename T>
const char* toCStr(const T &thing) {
std:
outStr << thing;
std::string Str=outStr.str();
return Str.c_str();
}
Does any body know what is its problem?
Thanks