Hi,
I have a problem with converting a C++ string into a long double. In order to do this, I used the function strtold, but the result I get is only the integral part, that is: if for example the input string is 12.476, I only get 12 as the converted long double value. This happens with atof too.
Here is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/*This is the include section*/
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <sstream>
/* Code giving problems */
string test = "12.345";
longdouble test_longd = strtold(test.c_str(),NULL);
/*The following is because I have to write the result in a WxWidgets component*/
ostringstream parte_dec_oss;
parte_dec_oss << testing;
WxRichTextCtrl1->WriteText(parte_dec_oss.str());
Could you help me? I can't figure out how to solve this issue.
Thanks.