MFC - printing string to .Format()

Hi ! I have a MFC app where I want to display a CString into a 'static' textbox using '.Format()'

Originally I had this in a switch statement and it worked fine:
1
2
const char *playerName = strPlayerName.c_str();
m_sPlayerName.Format(playerName);



Later, while expanding the code I had to change the timing for when I print the updated names...so I tried to make a copy to a new string within the cases of the switch statement which look like this:

1
2
3
//strPlayerName is a CString
size_t pos = strPlayerName.find(strPlayerName);
strPlayerTwoName = strPlayerName.substr(pos);



But...when trying to print the 'player__Name' outside the switch statement nothing shows up on the screen.
1
2
3
4
5
const char *playerTwoName = strPlayerTwoName.c_str();
m_sPlayerTwoName.Format(playerTwoName);

//strPlayerTwoName is here !!!
fout << strPlayerTwoName;


I've checked the strings using fstreams and they appear to be exactly as they should be. I know this must be some sort of bad 'copy' from one CString to another but I'm lost !!! Thank !
Last edited on
Is m_sPlayerTwoName bound to the static control?
Yes, it is bound to the static control.

Honestly, I'm not sure what happened but I worked on other components for a few hrs and now the .Format() is printing the way it should !! :/
I don't know what could have changed from then to now...my only guess is that I was putting together a fstream and mayyybe that affected things...but none of those strings were connected to it as far as I know...

Anyway...false alarm for now...Thanks for looking :)
Topic archived. No new replies allowed.