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 155 views
1 answer 165 views
2 answers 306 views
1 answer 174 views
1 answer 304 views
304 views asked Jun 20, 2021 by avibootz
1 answer 76 views
1 answer 118 views
...