So when you do something like...
MessageBox( NULL, &system, L"The system is", MB_OK );
you get what's in
System
displayed with the contents of
ConnectionList
?
If that's the case it's because
System
runs into
ConnectionList
. When
MessageBox
(or whatever uses
System
) expects System to be a
NULL
terminated string and it's not, it's just one character and the next terminator in memory is at the end of
ConnectionList
.
So what can you do about it? First thing is stop using functions that expect NULL terminated strings to manipulate stuff. It's never going to work with your structure. Secondly stop using wscpy, even C programmers avoid it as it's so easy to mess up with and go stomping all over memory you shouldn't. And if you really have to call a function that expects a constant zero terminated string for
System
buffer it:
std::wstring window_text_buffer( 1, objEntity );
MessageBox( NULL, text_buffer.c_str(), "The system is", MB_OK );
Final thing is start being a C++ programmer. I know this sounds harsh but all the time you're using C functions and casts your heart's not really in it. Or you're stuck in a early 1990s timwarp. Stop using structures that don't have any behaviour (occasionally you might have need of a data aggregate, but it's not often), investigate the C++ equivalents of what you're doing with C functions and stop using C style casts.