#include <stdlib.h>
double strtod( const char *start, char **end );
函数返回带符号的字符串 start 所表示的浮点型数。字符串 end 指向所表示的浮点型数之后的部分。如果溢出发生,返回HUGE_VAL 或 -HUGE_VAL。
#include <stdio.h>
#include <stdlib.h>
int main(void)
{
char input[80], *endptr;
double value;
printf("Enter a floating point number:");
gets(input);
value = strtod(input, &endptr);
printf("The string is %s the number is %lf\n", input, value);
return 0;
}输出结果:
Enter a floating point number:100 The string is 100 the number is 100.000000