A1METALHEAD
Programmer
are there any convertions between CString and char*? i hate CString... and i need a way to get a char*...
thanks,
~metalhead
thanks,
~metalhead
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
void chatAboutDlg::OnBnClickedSend()
{
int iSize;
char* p;
iSize = ipAddress.GetLength(); //get size of string
p = (char*)malloc(iSize); //initialize char* to size of string
strcpy(p,ipAddress);
free(p);
winChat = new winChatApp( 1200 , p );
m_send.SetWindowText("Send");
m_sendtextCon.SetWindowText("");
}
void chatAboutDlg::OnBnClickedSend()
{
char* tmpIP = new char[ipAddress.GetLength()+1];
strcpy(tmp, ipAddress);
winChat = new winChatApp( 1200 , tmpIP );
delete [] tmp;
m_send.SetWindowText("Send");
m_sendtextCon.SetWindowText("");
}
- this 0x00a731d0 {isSetup=true itsSocket=-842150451 portNum=-842150451 ...} winChatApp * const
isSetup true bool
itsSocket -842150451 int
portNum -842150451 int
bytes -842150451 int
- ip 0xcdcdcdcd <Bad Ptr> char *
CXX0030: Error: expression cannot be evaluated char
- lastSnd 0xcdcdcdcd <Bad Ptr> char *
CXX0030: Error: expression cannot be evaluated char
- lastRcv 0xcdcdcdcd <Bad Ptr> char *
CXX0030: Error: expression cannot be evaluated char
port 1200 int
- aIp 0x00a73190 "" char *
0 char
class winChatApp
{
public:
winChatApp(int,char*);
~winChatApp();
bool isSetup;
char* rev();
bool send(char*);
private:
int itsSocket;
int portNum;
int bytes;
char* ip;
char* lastSnd;
char* lastRcv;
int startupClient();
void shutdownClient();
};
winChatApp::winChatApp(int port , char* aIp)
{
strcpy( ip , aIp );
portNum = port;
itsSocket = startupClient();
if (itsSocket == -1)
{
shutdownClient();
return;
}
isSetup = true;
}
winChatApp::winChatApp(int port , [red]const[/red] char* aIp)
void chatAboutDlg::OnBnClickedSend()
{
winChat = new winChatApp( 1200 , ipAddress );
m_send.SetWindowText("Send");
m_sendtextCon.SetWindowText("");
}
#include <string>
std::string lpctstr2string(LPCTSTR s_in)
{
#ifdef _UNICODE
std::wstring w(s_in);
std::string s;
for(std::wstring::const_iterator it = w.begin();it!=w.end();++it)
s+=(*it);
return s;
#else
return s_in;
#endif
}
CString strHello("Hiya");
cout << lpctstr2string(strHello).c_str() << endl;