The %s directive makes printf() and friends expect a string pointer on the stack. If you pass an object, such as std::string, you'll give it "garbage". If you give it a pointer to the internal string buffer instead, it'll work.
I agree with David's suggestion. Passing C++ as a "optional" parameter yeilds undefined behaviour. With CStrings, you can do this, and I bet Microsoft engineers did some tweaking to make that work. I don't know about std::string, but chances are that they are not crafted in such a way that they will work with printf()-like functions...
I want to develop an MFC application that has
1. Either a control bar or dialog bar which has some button objects
2. The bar needs to be always accessible. That means I want to be able to click on the buttons on the bar even if a modal dialog showing.
One way I thought of to put the dialog bar in its user thread, but this is almost impossible as it dialog bar needs to send a message to the main windows. Another way was not to show modal dialogs, but this would complicate the design as to manage the number of different dialogs to be displayed.
Any thought as to how to put a controls bar/dialog bar/or even a child windows on its own thread that can always listen to user actions? A pointer to an article or sample code would be great.
/* I can C */
// or !C
Last Visit: 31-Dec-99 19:00 Last Update: 5-Dec-23 21:49