chintan s
chintan s

Reputation: 6488

convert the string from combobox to double

I am trying to do the following:

CCombobox m_obs;
CString temp;

m_obs.GetWindowTextA(temp);
double newObs = strtod(temp, NULL);

However, I get the error in strtod() that no suitable conversion function from CString to const char * exists.

How do I convert the string from combobox to double?

Upvotes: 0

Views: 880

Answers (3)

chintan s
chintan s

Reputation: 6488

Thanks for your replies.

For UNICODE projects, do the following:

double NewObs = wcstod(temp, NULL);

Upvotes: 1

AndersK
AndersK

Reputation: 36082

Try instead CStringA, to force use of the Ansi version otherwise CString is dependent on the compiler switch where UNICODE is default.

Upvotes: 2

Maroun
Maroun

Reputation: 95948

strtod() expect const char * str for the first argument. You should do:

const char* cstr = (LPCTSTR)temp;
double newObs = strtod(cstr, NULL);

Upvotes: 1

Related Questions