<p align= "Left" > Example: "12.34" return 12.34</p><p align= "left" > "123.34" return -123.34</p><p align= "Left" > Function prototype: doublemy_atof (char *str) </p><p align= "left" >{}</p>
#include <stdio.h> #include <math.h>int main () {double my_atof (char *str), char str[]= "123.4";p rintf ("%lf\n ", My_atof (str)); return 0;} Double My_atof (char *str) {int flag=1;double num=0;int count=0;int clark;while (*str!= ' + ') {if (*str== '-')//Positive negative number {flag= -1;str++;} if (*str== '. ') Determine if there is a decimal point {clark=1;str++;} if (clark==1) {count++;} if (*str>= ' 0 ') && (*str<= ' 9 '))//Determine whether the character 1 to 9 is between num=num*10+ (*str-' 0 '); str++;} Num=flag*num*pow (10,-count); return num;}
Write a function using the C language implementation to convert a numeric string to a number corresponding to the string (including positive floating-point numbers, negative floating-point numbers)