1. How to convert CString object to data type?
How can I convert CString from a EDIT control Dialog to data type for calculation? thanks,
2. how to convert CString object to data type
3. default data type for global variables
"qazmlp" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM ...
> This one compiles fine:
>
> // fileName.C
> someName = 2 ;
>
> int main()
> {
> someName = someName + 2 ;
> }
It probably compiles because of the .c extension in file name. The .c
extension causes some compilers to behave like a C compiler. In C++ you
must always specify the type, which is a good practice anyway, even in
C.
> But, the following gives compilation error:
>
> int main()
> {
> someName = 2 ;
> someName = someName + 2 ;
> }
>
> Why? I would like to have the C++ standard word also about this.
> Also, what is the default data type assumed in the first case?
This is is really a C question, it is not valid C++ code. C defaults to
int when no type is specified.
4. C# data type keywords v. .Net data types - CSharp/C#
5. How to convert CString type to LPCSTR type
Hi,
I have a CString type variable, and I need to convert it's to LPCSTR
type ,what I can do!
example:
CString m_strExecFile(_T("C:\\\\aa.exe"));
next I want to call WinExec Command to execute this file
LPCSTR lpcstr ;
lpcstr = m_strExecFile.GetBuffer();
WinExec(lpcstr,SW_SHOW);
BUT the compilier tells me it can not convert w_char * to LPCSTR type!
Why?
ps. I use vs2005 program in UNICODE mode.
Any helpful ideas would be highly appreciated!
-joseph
6. Default type-value for template parameter type
7. Derived CAsyncSocket sends duplicate data?
I'm at a loss here. I've looked at it, and it's probably something
simple, but can someone explain why my derived class sends duplicate
sets of data occasionally (IE 1 call to Send makes it received twice on
the other end)?
As far as I can tell, it only occurs when the system is under high CPU
load.
Thanks in advance.
Josh McFarlane
--------
>From Header File:
enum SendStatus //State of the Send Buffer
{
SEND_EMPTY, //Empty Send Queue
SEND_ACTIVE //Sending currently in progress
};
CCriticalSection ctSender;
SendStatus c_SendStatus;
size_t bytesSent;
size_t sendlength;
std::vector<BYTE> outBuffer;
-----------
>From CPP:
int CInternalSocket::Send(const void* lpBuf, int nBufLen, int)
{
//Need to add DWORD to buffer before sending
DWORD TotalLength = nBufLen + sizeof(DWORD);
DWORD Length = htonl(nBufLen);
{
CSingleLock lock(&ctSender);
lock.Lock();
switch (c_SendStatus)
{
case SEND_EMPTY:
{
bytesSent = 0;
sendlength = TotalLength;
outBuffer.resize(TotalLength, 0);
BYTE* p = &outBuffer[0];
memcpy(p, &Length, sizeof(DWORD));
p += sizeof(DWORD);
memcpy(p, lpBuf, nBufLen);
c_SendStatus = SEND_ACTIVE;
break;
}
case SEND_ACTIVE:
{
size_t oldSize = outBuffer.size();
sendlength = oldSize + TotalLength;
outBuffer.resize(sendlength, 0);
BYTE* p = &outBuffer[oldSize];
memcpy(p, &Length, sizeof(DWORD));
p += sizeof(DWORD);
memcpy(p, lpBuf, nBufLen);
break;
}
}
}
OnSend(ERROR_SUCCESS);
return nBufLen;
}
void CInternalSocket::OnSend(int nErrorCode)
{
CSingleLock lock(&ctSender);
lock.Lock();
if (nErrorCode != ERROR_SUCCESS)
{
//Handle initial socket errors here.
if(pInterface)
{
pInterface->PostThreadMessage(UWM_SOCKET_SENDERROR, nErrorCode,
NULL);
}
return;
}
//Check buffer to make sure that it has data to be sent.
size_t bytesToSend = sendlength - bytesSent;
BYTE* p = &outBuffer[bytesSent];
while(bytesToSend > 0)
{ //Bytes to send
int len = CAsyncSocket::Send(p, bytesToSend);
if (len == SOCKET_ERROR)
{ //Send Error
int lastErr = ::GetLastError();
if (WSAEWOULDBLOCK == lastErr || WSAENOTCONN == lastErr)
{
break;
}
else
{
if(pInterface)
{
pInterface->PostThreadMessage(UWM_SOCKET_SENDERROR, lastErr,
NULL);
}
break;
}
} //Send Error
bytesToSend -= len;
bytesSent += len;
p += len;
} //Bytes to Send
if (bytesSent >= outBuffer.size())
{
bytesSent = 0;
c_SendStatus = SEND_EMPTY;
}
}