C++ string in a windows function
Hi.
For example:
If I use GetWindowText, I use it as follows:
Code:
char WindowCaption [ 1024 ];
GetWindowText ( Window, WindowCaption, 1024 );
Easy, but let's say I want to do something with the string, to easly work with it, I put it in a C++ string, I prefer to work with C++ strings.
Code:
std :: string Caption = WindowCaption;
Done, only the thing is I need to use two strings.
I am able to directly use a C++ string in the following code:
Code:
MessageBox ( Window, "Message Box Text", Caption.c_str(), MB_OK );
As you can see I used the c_str() function, but when I try the following, the c_str() function wont help:
Code:
std :: string WindowCaption;
GetWindowText ( Window, WindowCaption.c_str(), 1024 );
It will give me a compile error so I tried a lot of things but they all didn't work.
I actually have this problem quite long but I never bothered about it, I always just used two strings.
Only now I really would like to only use one C++ string with GetWindowText, can someone help me how to that?
Thank you, Yuri.