Click here to Skip to main content
15,922,145 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
Albert Holguin17-Sep-14 10:24
professionalAlbert Holguin17-Sep-14 10:24 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
jschell18-Sep-14 8:34
jschell18-Sep-14 8:34 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
Albert Holguin18-Sep-14 10:03
professionalAlbert Holguin18-Sep-14 10:03 
AnswerRe: Migrating from Win.MFC to Linux/??? Pin
Bram van Kampen17-Sep-14 13:28
Bram van Kampen17-Sep-14 13:28 
AnswerRe: Migrating from Win.MFC to Linux/??? Pin
Albert Holguin17-Sep-14 8:34
professionalAlbert Holguin17-Sep-14 8:34 
AnswerRe: Migrating from Win.MFC to Linux/??? Pin
bling17-Sep-14 8:54
bling17-Sep-14 8:54 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
Albert Holguin17-Sep-14 10:47
professionalAlbert Holguin17-Sep-14 10:47 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
Bram van Kampen17-Sep-14 13:33
Bram van Kampen17-Sep-14 13:33 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
SoMad17-Sep-14 14:04
professionalSoMad17-Sep-14 14:04 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
Albert Holguin17-Sep-14 16:40
professionalAlbert Holguin17-Sep-14 16:40 
GeneralRe: Migrating from Win.MFC to Linux/??? Pin
bling18-Sep-14 8:51
bling18-Sep-14 8:51 
AnswerRe: Migrating from Win.MFC to Linux/??? Pin
jschell17-Sep-14 10:01
jschell17-Sep-14 10:01 
QuestionCrypto API Question Pin
Drakesal16-Sep-14 5:24
Drakesal16-Sep-14 5:24 
AnswerRe: Crypto API Question Pin
Richard MacCutchan16-Sep-14 5:36
mveRichard MacCutchan16-Sep-14 5:36 
QuestionCMenus : How to use menu handles instead of menu resource ID when needed ? Pin
sdancer7515-Sep-14 20:45
sdancer7515-Sep-14 20:45 
AnswerRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
Richard MacCutchan15-Sep-14 21:19
mveRichard MacCutchan15-Sep-14 21:19 
AnswerRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
CPallini15-Sep-14 21:22
mveCPallini15-Sep-14 21:22 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
sdancer7515-Sep-14 22:07
sdancer7515-Sep-14 22:07 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
CPallini15-Sep-14 23:04
mveCPallini15-Sep-14 23:04 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
Richard MacCutchan16-Sep-14 2:30
mveRichard MacCutchan16-Sep-14 2:30 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
sdancer7516-Sep-14 21:35
sdancer7516-Sep-14 21:35 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
Richard MacCutchan16-Sep-14 21:57
mveRichard MacCutchan16-Sep-14 21:57 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
Richard MacCutchan16-Sep-14 2:29
mveRichard MacCutchan16-Sep-14 2:29 
GeneralRe: CMenus : How to use menu handles instead of menu resource ID when needed ? Pin
CPallini16-Sep-14 2:45
mveCPallini16-Sep-14 2:45 
QuestionPassing a class to a sprintf() and similar Pin
Crazy Joe Devola14-Sep-14 19:45
Crazy Joe Devola14-Sep-14 19:45 
I am trying to pass a class I wrote to sprintf(). Not the class itself actually, but a pointer to a string the class holds.

With the VC++ CString class it works fine:
sprintf(t, "%s", cst);

But with my class, it either crashes the program or puts garbage into the t buffer:
sprintf(t, "%s", c);

Unless I use casting, and then it works ok:
sprintf(t, "%s", (char *)c);

What is my class missing? Some kind of an operator?
Here is my code:


C++
class C1
{
public:
C1()
{
sprintf(m_Data,"C1 class");
}

operator char *() { return m_Data; }

private:
char m_Data[100];
};

int main(int argc, char* argv[])
{
char t[1000]="";
C1 c;
CString cst("Test c string");

sprintf(t, "%s", cst);
sprintf(t, "%s", c);
return 0;
}

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.