系统提供的,还有很多这种相关函数,我给你列出来,以备后用: abs Find absolute value of integer atof Convert string to float atoi, _atoi64 Convert string to int atol Convert string to long _ecvt Convert double to string of specified length _fcvt Convert double to string with specified number of digits following decimal point _gcvt Convert double number to string; store string in buffer _itoa, _i64toa, _itow, _i64tow Convert int to string labs Find absolute value of long integer _ltoa, _ltow Convert long to string _mbbtombc Convert 1-byte multibyte character to corresponding 2-byte multibyte character _mbcjistojms Convert Japan Industry Standard (JIS) character to Japan Microsoft (JMS) character _mbcjmstojis Convert JMS character to JIS character _mbctohira Convert multibyte character to 1-byte hiragana code _mbctokata Convert multibyte character to 1-byte katakana code _mbctombb Convert 2-byte multibyte character to corresponding 1-byte multibyte character mbstowcs Convert sequence of multibyte characters to corresponding sequence of wide characters mbtowc Convert multibyte character to corresponding wide character strtod, wcstod Convert string to double strtol, wcstol Convert string to long integer strtoul, wcstoul Convert string to unsigned long integer strxfrm, wcsxfrm Transform string into collated form based on locale-specific information __toascii Convert character to ASCII code tolower, towlower, _mbctolower Test character and convert to lowercase if currently uppercase _tolower Convert character to lowercase unconditionally toupper, towupper, _mbctoupper Test character and convert to uppercase if currently lowercase _toupper Convert character to uppercase unconditionally _ultoa, _ultow Convert unsigned long to string wcstombs Convert sequence of wide characters to corresponding sequence of multibyte characters wctomb Convert wide character to corresponding multibyte character _wtoi Convert wide-character string to int _wtol Convert wide-character string to long
float data = atof(str);OK!
#include <stdio.h>
void main( void )
{
char *s;
double x;
s = "7.89";
x = atof( s );}
float data = atof(str);难到不对吗???
float data = atof(str);
是对的
abs Find absolute value of integer
atof Convert string to float
atoi, _atoi64 Convert string to int
atol Convert string to long
_ecvt Convert double to string of specified length
_fcvt Convert double to string with specified number of digits following decimal point
_gcvt Convert double number to string; store string in buffer
_itoa, _i64toa, _itow, _i64tow Convert int to string
labs Find absolute value of long integer
_ltoa, _ltow Convert long to string
_mbbtombc Convert 1-byte multibyte character to corresponding 2-byte multibyte character
_mbcjistojms Convert Japan Industry Standard (JIS) character to Japan Microsoft (JMS) character
_mbcjmstojis Convert JMS character to JIS character
_mbctohira Convert multibyte character to 1-byte hiragana code
_mbctokata Convert multibyte character to 1-byte katakana code
_mbctombb Convert 2-byte multibyte character to corresponding 1-byte multibyte character
mbstowcs Convert sequence of multibyte characters to corresponding sequence of wide characters
mbtowc Convert multibyte character to corresponding wide character
strtod, wcstod Convert string to double
strtol, wcstol Convert string to long integer
strtoul, wcstoul Convert string to unsigned long integer
strxfrm, wcsxfrm Transform string into collated form based on locale-specific information
__toascii Convert character to ASCII code
tolower, towlower, _mbctolower Test character and convert to lowercase if currently uppercase
_tolower Convert character to lowercase unconditionally
toupper, towupper, _mbctoupper Test character and convert to uppercase if currently lowercase
_toupper Convert character to uppercase unconditionally
_ultoa, _ultow Convert unsigned long to string
wcstombs Convert sequence of wide characters to corresponding sequence of multibyte characters
wctomb Convert wide character to corresponding multibyte character
_wtoi Convert wide-character string to int
_wtol Convert wide-character string to long
float data = atof(str);