Original Post
Hi all, I am trying to use sscanf to extract an exponential value from a string, which should work according to the documentation. But, in my code, it doesn't seem to be working, the exponential value retrieved is not the correct value. Do you see any errors?
#include<iostream>
#include<string>
using namespace std;
int main()
{
char str[]="240.0000 2.015E+02 2.020E+01";
float junk;
double val1, val2;
sscanf(str, "%f %e %e", &junk, &val1, &val2);
cout<<junk<<endl;
cout<<val1<<endl;
cout<<val2<<endl;
}