How to convert string with two values to two float numbers in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h> 
 
int main(void) {
    char arr[] = "234.012 3.14";
    char *p;
 
    float f1 = strtod(arr, &p);
    float f2 = strtod(p, NULL);
 
    printf("%f\n", f1);
    printf("%f\n", f2);
     
    return 0;
}
 
 
 
 
/*
run:
 
234.011993
3.140000
 
*/

 



answered Jun 20, 2021 by avibootz

Related questions

1 answer 198 views
1 answer 166 views
1 answer 165 views
2 answers 213 views
1 answer 220 views
...