标签:
#include <stdlib.h> #include <stdio.h> int main() { double c = 0; char *endptr; c = strtod("200e-2",&endptr); printf("原始字符串:200e-2\t转换后:%f\t返回字符串:%s\n",c,endptr); c = strtod("123%^456",&endptr); printf("原始字符串:123%^456\t转换后:%f\t返回字符串:%s\n",c,endptr); c = strtod("#$%123%^098",&endptr); printf("原始字符串:#$%123%^098\t转换后:%f\t返回字符串:%s\n",c,endptr); c = strtod(" ",&endptr); printf("原始字符串: \t转换后:%f\t返回字符串:%s\n",c,endptr); c = strtod("0.55",&endptr); printf("原始字符串:0.55\t转换后:%f\t返回字符串:%s\n",c,endptr); c = strtod("145789632",&endptr); printf("原始字符串:145789632\t转换后:%f\t返回字符串:%s\n",c,endptr); c = strtod("$#@!",&endptr); printf("原始字符串:$#@!\t转换后:%f\t返回字符串:%s\n",c,endptr); return 0; }
运行结果:
标签:
原文地址:http://blog.csdn.net/kongshuai19900505/article/details/51914035