Reading ASCII numbers using "D" instead of "E" for scientific notation using C

Posted by Arrieta on Stack Overflow See other posts from Stack Overflow or by Arrieta
Published on 2010-03-31T17:30:59Z Indexed on 2010/03/31 17:33 UTC
Read the original article Hit count: 393

Filed under:
|
|
|
|

Hello,

I have a list of numbers which looks like this: 1.234D+1 or 1.234D-02. I want to read the file using C. The function atof will merely ignore the D and translate only the mantissa. The function fscanf will not accept the format '%10.6e' because it expects an E instead of a D in the exponent. When I ran into this problem in Python, I have up and merely used a string substitution before converting from string to float. But in C, I am sure there must be another way.

So, how would you read a file with numbers using D instead of E for scientific notation? Notice that I do not mean how to read the strings themselves, but rather how to convert them to floats.

Thanks.

© Stack Overflow or respective owner

Related posts about c

    Related posts about scientific-notation