【发布时间】:2017-08-17 00:42:03
【问题描述】:
这可能是一个非常愚蠢的问题,但我不明白...为了从 ASCII 表示转换为相关数字,我在 Visual Studio 2012 中使用 strtof()。根据https://msdn.microsoft.com/en-us/library/dn320175.aspx(和accordng to使用 gcc 可以正常编译的 Linux 手册页)需要包含 stdlib.h。
现在我的问题:我的文件中已经有一个#include <stdlib.h>,但仍然出现这个编译错误!
知道可能缺少什么吗?
谢谢!
编辑:代码示例
#include <stddef.h>
#include <stdlib.h>
static char *get_xyz(char *c,float *x,float *y,float *z)
{
c++;
if ((*c=='X') || (*c == 'A') || (*c=='x') || (*c=='a'))
{
c++;
if (*c) *x=strtof(c,NULL);
}
if ((*c=='Y') || (*c=='B') || (*c=='y') || (*c=='b'))
{
c++;
if (*c) *y=strtof(c,NULL);
}
if (z)
{
if ((*c=='Z') || (*c=='C') || (*c=='z') || (*c=='c'))
{
c++;
if (*c) *z=strtof(c,NULL);
}
}
return c;
}
【问题讨论】:
-
你能展示一个 MCVE 吗? stackoverflow.com/help/mcve
-
发布错误和代码。
-
对应于 Visual Studio 2013 或更高版本。使用
strtod而不是strtof。 -
@BLUEPIXY:谢谢,这就是解决方案!
标签: c visual-studio visual-studio-2012