octopuszhang 发表于 2009-4-13 19:56:35

类型转换

请问CVI中有没有将字符串转成double数据的函数,比如“0.123”转换成0.123,发现有atoi可以转换整型的数据,但是转成double型的好像没有发现。在自己写转换函数之前,请教一下CVI是否已经有这样的功能函数。

胆生毛 发表于 2009-4-13 19:59:49

Converts the initial portion of a string to double representation. The function skips whitespace characters at the beginning of the string. The conversion stops when a character that cannot be part of a number is reached. strtod obtains a pointer to the unconverted part of the string. The expected form of the subject sequence is an optional plus or minus sign, then a nonempty sequence of digits optionally containing a decimal-point character, then an optional exponent part.



Prototype

double strtod (const char String_Input[], char **End_Pointer);

octopuszhang 发表于 2009-4-13 20:05:41

谢谢!发现原来还有atof这个函数可以用,楼上给的也可以用。

panheping 发表于 2009-4-13 20:49:49

dui

panheping 发表于 2009-4-13 20:49:59

和c的一样

hcwz 发表于 2009-4-14 19:38:34

char *s;
double x;
s = "12.3";
Scan (s, "%s>%f", &x);
得到的x = 12.3,是double型数据
页: [1]
查看完整版本: 类型转换