【发布时间】:2012-02-19 13:34:34
【问题描述】:
我需要从一个字符串中获取一些双精度值。
string data = getMyData();
char** next;
double start = strtod(data.c_str(), next);
if (&data == &(*next)) //check wether a double has been found - not working
{
std::cerr << "Value can't be read.\nAborting.";
return;
}
我的想法是检查数据的第一个字符和下一个字符的内存地址。 目前我正在自学中学习 C++,所以如果能得到最好的解决方案,而不仅仅是一个可行的解决方案,那就太好了。
【问题讨论】:
标签: c++ string double type-conversion