How to convert string with two values to two long double numbers in C

1 Answer

0 votes
#include <stdio.h>
#include <stdlib.h> 
 
int main(void) {
    char s[] = "940284.712 4728223.7309";
    char *p;
  
    long double ld1 = strtold(s, &p);
    long double ld2 = strtold(p, NULL);
    
    printf("%Lf %Lf", ld1, ld2);

    return 0;
}
 
 
 
 
 
/*
run:
 
940284.712000 4728223.730900
 
*/

 



answered Jun 20, 2021 by avibootz

Related questions

1 answer 152 views
1 answer 164 views
2 answers 301 views
1 answer 171 views
1 answer 303 views
303 views asked Jun 20, 2021 by avibootz
1 answer 75 views
1 answer 115 views
...