Write function Implementation Library functions Atof#include <stdio.h> #include <assert.h> #include <ctype.h> #include <math.h> Double Calculate (const char *SRC, int flag) {Double num = 0.0;int N = 0;int count = 0;while (*SRC) {if ((*src >= ' 0 ') &am p;& (*src <= ' 9 '))//infer if the input is a non-array character {num = num * + (*SRC-' 0 '); src++;if (n) {count++;}} else if (*src = = '. ') {n = 1;src++;} Else{num = 0;break;}} if (n) {num = Num/powl (10,count);} return flag * NUM;} Double str_to_int (const char *str) {Double num = 0.0;int flag = 1;if (str! = NULL && *str! = ') ' {while (isspace (* STR) {str++;} if (*str = = ' + ') str++;else if (*str = = '-') {str++;flag =-1;} if (*str! = ')} {num = calculate (str, flag);}} return num;} int main () {printf ("%f\n", Str_to_int ("+23.45"));p rintf ("%f\n", Str_to_int (" -2.345"));p rintf ("%f\n", Str_to_int ("+ 234.5 "));p rintf ("%f\n ", Str_to_int (" -2345.44 "));p rintf ("%f\n ", Str_to_int (" 2345 "));p rintf ("%f\n ", Str_to_int ("- 1111.11 "));p rintf ("%f\n ", Str_to_int (" "));p rintf ("%f\n ", Str_to_int (" 123ab ")); reTurn 0;}
"C Language" write function implement library function atof