Click here to Skip to main content
15,920,896 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Converting text to float (MFC) Pin
Bob Ciora26-Jan-05 7:27
Bob Ciora26-Jan-05 7:27 
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 7:49
Member 166473326-Jan-05 7:49 
GeneralRe: Converting text to float (MFC) Pin
Bob Ciora26-Jan-05 8:03
Bob Ciora26-Jan-05 8:03 
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 8:26
Member 166473326-Jan-05 8:26 
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 8:28
Member 166473326-Jan-05 8:28 
GeneralRe: Converting text to float (MFC) Pin
Bob Ciora26-Jan-05 8:59
Bob Ciora26-Jan-05 8:59 
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 9:05
Member 166473326-Jan-05 9:05 
GeneralRe: Converting text to float (MFC) Pin
Bob Ciora26-Jan-05 9:21
Bob Ciora26-Jan-05 9:21 
Actually... CString has a LPCTSTR operator that will perform the conversion automatically in many cases. So:

CString sFloat = "123.45";

// This will compile without error and run successfully:
const char * szText = sFloat;

// So will this:
float boxval;
int nArgs = sscanf(sFloat, "%s", &boxval);

// As will this:
double d = atof(sFloat);


In all three cases, the compiler understands (based on the l-value in the assignment statements and the prototypes for sscanf and atof) that you're using the LPCTSTR operator for CString.

The code above will compile and run successfully, and boxval and d will be 123.45.

I have a sneaking suspicion that you've changed something elsewhere in the program, even a minor change, and it fixed the problem.


Bob Ciora
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 9:31
Member 166473326-Jan-05 9:31 
GeneralRe: Converting text to float (MFC) Pin
David Crow26-Jan-05 9:59
David Crow26-Jan-05 9:59 
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 10:06
Member 166473326-Jan-05 10:06 
GeneralRe: Converting text to float (MFC) Pin
David Crow26-Jan-05 10:11
David Crow26-Jan-05 10:11 
GeneralRe: Converting text to float (MFC) Pin
Bob Ciora26-Jan-05 10:43
Bob Ciora26-Jan-05 10:43 
GeneralRe: Converting text to float (MFC) Pin
David Crow26-Jan-05 8:53
David Crow26-Jan-05 8:53 
GeneralRe: Converting text to float (MFC) Pin
Tom Wright26-Jan-05 8:45
Tom Wright26-Jan-05 8:45 
GeneralRe: Converting text to float (MFC) Pin
Member 166473326-Jan-05 8:53
Member 166473326-Jan-05 8:53 
GeneralCDialog Question Pin
Anonymous26-Jan-05 5:53
Anonymous26-Jan-05 5:53 
GeneralRe: CDialog Question Pin
David Crow26-Jan-05 5:59
David Crow26-Jan-05 5:59 
GeneralRe: CDialog Question Pin
Anonymous26-Jan-05 6:26
Anonymous26-Jan-05 6:26 
GeneralRe: CDialog Question Pin
David Crow26-Jan-05 6:44
David Crow26-Jan-05 6:44 
GeneralRe: CDialog Question Pin
poiut26-Jan-05 8:36
poiut26-Jan-05 8:36 
GeneralRe: CDialog Question Pin
David Crow26-Jan-05 8:41
David Crow26-Jan-05 8:41 
GeneralRe: CDialog Question Pin
Blake Miller26-Jan-05 8:43
Blake Miller26-Jan-05 8:43 
GeneralRe: CDialog Question Pin
Anonymous26-Jan-05 9:20
Anonymous26-Jan-05 9:20 
GeneralRe: CDialog Question Pin
Blake Miller26-Jan-05 11:26
Blake Miller26-Jan-05 11:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.