I'm trying to program a chatting program.
I ask you guys for help since I have little problem.
when I try to send a CString
formatted strings, it only receives first letter of the string.
I'm using CAsyncSocket
for sockets.
I tried it with char*
format string, it worked.
Can you guys tell me what is wrong?
My code is like below:
worked.
char* buf = new char[m_strMsg.GetLength()];
buf = "helloworld!";
m_ClientSocket.Send("sended", m_strMsg.GetLength());
m_ClientSocket.Send(buf, 10);
not worked.
CString a = _T("helloworld!");
m_ClientSocket.Send(a,10);
I've also tried:
CString a = _T("helloworld!");
char* buf = new char[a.GetLength()];
buf = (LPSTR)(LPCTSTR)a;
m_ClientSocket.Send(buf,a.GetLength()];