On 30 Oct 2005 10:22:33 -0800, "Nemok" <> wrote:
>Thanks for your answers.
>
>Something more:
>1. How can I use std::stringstream to convert to and from integer/float
>and string types ? I searched for it but found nothing usefull.
>2. How can I convert characters in a std::string to low characters.
>(like MakeLower() in CString)
1. How about this? (untested code follows...)
template<typename NumericType>
typename NumericType ToNumber<NumericType>(
std::string const &s) {
NumericType retval;
std::istringstream iss(s);
iss >> retval;
return retval;
}
Obviously, this is NOT robust code ... but it may well serve your
purpose. In particular, it doesn't do any sanity checking WRT bounds
checking, no exception safety, etc.
2. I would use the CRT functions (tolower(), toupper(), etc.) but only
if you do not need any i18n support ... otherwise, you need to look
into locales and facets, especially codecvt.
--
Bob Hairgrove