|
They make USB to parallel adapters. I suggest this as you say you have previously done your robotic control via a parallel port. There's a chance that your existing code that works through a real parallel port might work with one of these.
|
|
|
|
|
I use std::wstring for unicode.
To write a file with wstring, I need the memory size of wstring.
But I couldn't find the method about memory size.
wstring::size() and wstring::length() show only the length of characters.
for example,
std::wstring strText = L"ABC";
In the example, length of strText is '3'
But memory size of strText is '6' (in windows)
Is there any method to get memory size of std::wstring?
Thanks your help
David.
|
|
|
|
|
You can always multiply the string length by sizeof(wchar_t) to get the exact memory size.
|
|
|
|
|
Look at the capacity method.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
This method returns the full capacity (in element, not in bytes) of the string. It means that it can be larger than the actual size of your string (and it is still not expressed in bytes).
|
|
|
|
|
Isn't that what the OP is about?
To convert it to bytes you can do this.
size_t memsize = sizeof(wstring::value_type) * strText.capacity();
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
No, as far as I understood he wants to retrieve the lenght (in bytes and not in 'characters') of the string. For a string, the lenght is the same as the size in memory because one char equals one byte, which is not the case for a wstring.
|
|
|
|
|
If that's the case
size_t memsize = sizeof(wstring::value_type) * strText.size();
After reading the OP again, I think you're right.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
That was more or less my answer, but I have to agree that yours is more elegant
|
|
|
|
|
The basic_string::size() returns array size of <element> but not always the same to the character length.
Some new characters have 4 bytes (means wchar_t[2]) in each one character at the new unicode specification named JIS2004 in Japan.
They are so called surrogate-pair and someone said some characters have 6 bytes in some other countries. (I have not checked the specification yet. )
|
|
|
|
|
Do you mean you want to write the wstring to a file? With the null-terminator? Or what?
Anyway - the amount of memory taken up by the string data (i.e. the characters pointed at by the c_str() or data() methods) is size() * sizeof (std::wstring::value_type) (not including the null terminator).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Why am I getting this error?
Error 1 error C2228: left of '.checked' must have class/struct/union
Here's my code.
UpdateData(TRUE);
m_Summary += m_Name;
m_Summary += char(13);
m_Summary += char(10);
m_Summary += m_Address;
m_Summary += char(13);
m_Summary += char(10);
m_Summary += m_Phone;
if (m_Small.checked==true)
{
m_Summary += "Small Size 5.00";
}
UpdateData(FALSE);
|
|
|
|
|
Ryuk1990 wrote: if (m_Small.checked==true)
{
m_Summary += "Small Size 5.00";
}
How is m_Small declared?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
When I do view declaration, it shows me this code.
public:
int m_Small;
|
|
|
|
|
Ryuk1990 wrote: Error 1 error C2228: left of '.checked' must have class/struct/union
That is exactly what the error says.
Fundamental data types do not have any members that you can call that way.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
So how should the code be rewritten?
|
|
|
|
|
That totally depends on why m_Small was declared.
My guess would be
if (m_Small == true)
or
if (m_Small == TRUE)
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
use a #define and then do the checking.
|
|
|
|
|
Hi,
Using Vc++ how would i know whether i have inserted disk in the Drive of my machine ..and if inserted how can i get the drive in which i inserted the disk...
|
|
|
|
|
|
You do not need to call RegisterDeviceNotification .
You simply handle the WM_DEVICECHANGE message.
The system broadcasts the message to all top level applications.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Superman is correct in that you simply need to handle the WM_DEVICECHANGE message. I thought you might be interested in the Microsoft support article below:
How to receive notification of CD-ROM insertion or removal[^]
It also describes how to detect the CD/DVD removal by checking for the DBT_DEVICEREMOVECOMPLETE event.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi
I'm new to programming - but do use AHK a lot
Where do I start learning?
Is there a tutorial or disucssion board for n00bs?
Thanks
|
|
|
|
|
Learning CPP language wrote: Where do I start learning?
Books, Web sites, etc. Pick up a free compiler (e.g., Visual Studio Express) and just start tinkering.
Learning CPP language wrote: Is there a tutorial or disucssion board for n00bs?
Yes, the one you are on now is for C / C++ / MFC.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi I have a machine with several network interfaces that route through different NAT VPNs.
I've created a testing application that bind()s to one of these interfaces before calling connect(), which works excellent in Windows 7. When I try the same thing in Windows XP, bind() succeeds, but connect() fails with 10065 (WSAEHOSTUNREACH) after some seconds of blocking. I checked Wireshark, and there isn't even one single packet sent/received on each interface.
Any ideas what may be the problem?
Don't try it, just do it!
|
|
|
|