The other answers that discuss the difference between CStringA and CStringW are correct. You're dealing with an ASCII vs Unicode issue.
The Microsoft method to deal with this involves the use of a few macros.
TCHAR represents a character type and will automatically resolve to ASCII or Unicode depending on your project settings.
LPCSTR is a type defe to convert CStringA to const char *
LPCTSTR is a type defe to convert CString to TCHAR *
LPCWSTR is a type defe to convert CString to const wchar_t *
_tcscpy is an analog of strcpy, but will resolve to whichever tpye that TCHAR resolves to.
To do it the Microsoft recommended way:
struct userdata
{
TCHAR strUserName[20];
TCHAR strMsg[100];
}
CString m_txtSend;
_tcscpy(uinf.strMsg, m_txtSend);
CString sUserName;
sUserName.Format("%s : %s", udata->strUserName, udata->strMsg);
If you must use char, then there is a way to make that work if you know that you're strings will always be ASCII.
struct userdata
{
char strUserName[20];
char strMsg[100];
}
CString m_txtSend;
strcpy(uinf.strMsg, (LPCSTR) (CStringA) m_txtSend);
When using format to convert between Unicode and ASCII or vice versa, use the uppercase %S.
CString sUserName;
sUserName.Format("%S : %S", udata->strUserName, udata->strMsg);