我根本找不到这个函数在哪个库/头中,我看过很多使用这个函数的例子,但是没有结果……以下是我所包含的所有内容:
#include "Console.h"
#include "Direct3D9.h"
#include <string>
#include <cerrno>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
但是,strtof仍然出现为“错误命名空间"std”没有成员"strtof"“
我想要做的是:
flValue = std::strtof( vszArgs.at( 1 ).c_str( ), NULL );
pConVar->Set( flValue );
发布于 2015-05-28 22:54:12
Visual Studio 2012不实现strtof
。
Link to MSDN bug report,其中包括建议的解决方法。
发布于 2015-05-28 22:49:36
1)包含stdlib.h
#include <stdlib.h> /* strtof */
来自http://www.cplusplus.com/reference/cstdlib/strtof/
如果这还不起作用..。
2)确保您的编译器是C++11或更高版本
对于C++11来说,它是新的,所以如果你有一个旧的编译器,它将不能工作。
如果这还不起作用..。
3)您的编译器可能不支持它
Visual C++ 2012不完全支持C++11标准。请参阅Visual Studio bug "Missing strtof, strtold, strtoll, strtoull functions from stdlib.h"。
我们还没有在阴极射线管中实现这些功能。我们将考虑将它们添加到未来版本的Visual C++中。
发布于 2015-05-28 22:50:03
在使用C++11时,您可以在cstdlib
中找到。相关信息可以在以下位置轻松找到:http://www.cplusplus.com/reference/cstdlib/strtof/?kw=strtof
我的猜测是,您没有使用c++11进行编译。
https://stackoverflow.com/questions/30518299
复制相似问题