string转化为float的问题
如题,我想将string转化为float,我用的是float f=atof(str);
然后报错如下
error C2664: 'atof' : cannot convert parameter 1 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
请教错在哪里?怎么解决?不一定要用string,只要输入一个字符串再转换成浮点数就行;
还有我想要小数点后达到7位,float是不是不够?