|
I have looked for the symbol myself in the LIBs that come with Visual Studio 2005 and, sure enough, it wasn't there.
So I guess you'd have to define it yourself:
const GUID GUID_DEVICE_BATTERY = {0x72631e54L, 0x78A4, 0x11d0, {0xbc, 0xf7, 0x00, 0xaa, 0x00, 0xb7, 0xb3, 0x2a }};
Florin Crişan
|
|
|
|
|
GUID_DEVICE_BATTERY is defined in the BatClass.h file and internally uses the DEFINE_GUID macro. You must include <initguid.h> in one of your source files before you include BatClass.h.
Judy
|
|
|
|
|
I am working on hashing homework code and i have hit a wall.
The first time through a while loop, it works fine, but every time after that, it is not working correctly.
The output currently looks like:
ending address: Cluster size:
4 5 <- this is correct
97 0 <- this should be 1
116 0 <- this should be 1
241 5 <- this should be 6
Here is the code i wrote:
void HashTable::clusterCount(void)
{
unsigned long numClusters=0;
unsigned long clusterLength=0;
unsigned long i=0;
unsigned long totalLength = 0;
while(i<tableSize)
{
//startCluster=clusterLength;
clusterLength = 0;
while((i<tableSize)&&(hashTableArray[i]!=0)){
clusterLength++;
i++;
}
totalLength += clusterLength;
cout<< (i-1) <<" "<< clusterLength <<endl;
while((i<tableSize)&&(hashTableArray[i]==0))
{
i++; // increments i when the array address is empty
}
numClusters++;
i++;
}
cout<<"average cluster Length "<<totalLength/numClusters<<endl;
cout<<"numClusters "<<numClusters<<endl;
}
|
|
|
|
|
i has been changed in inner while loop.
Regards,
Paresh.
|
|
|
|
|
D'oh!! Too many i++
Arrg.. ive been looking at that for 2 hours and i missed it.
Thanks!!!
~Drew
|
|
|
|
|
Regards,
Paresh.
|
|
|
|
|
Hello all,
I am making client server application in c++.
I am using following lines of code.
int m_sock = socket(AF_INET, SOCK_STREAM, 0 );
but m_sock contains -1 and it is not creating socket for me.
Any body know how can i solve this problem?
Thanks in advance
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
My reply is a little off topic: don’t use the “m_” Hungarian prefix on local variables! It’s meant to indicate class members.
Steve
|
|
|
|
|
its ok but whats the solution for me.?
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
|
WSAGetLastError() can help when socket APIs return an error.
I'm guessing you're either getting WSAEPROTOTYPE because you haven't specified a
protocol type or you're getting WSANOTINITIALISED because you haven't called
WSAStartup().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
So, once again i must break away from c# and use c++. Not much of a probem really, until i get to something as simple as this.
So, i have a struct for a my colours, using floats for the RGB values because OpenGL really likes floats, meh. Anyway, i thought i'd add a constructor for it, and i come to the problem...
struct ColourRGB {
float Red;
float Green;
float Blue;
ColourRGB(float Red=0, float Green=0, float Blue=0);
};
All good. But, how can i make sure i set ColourRGB.Red to the parameter Red? Or must i just change the names of the parameters?
One day i'll read a book on c++ or something
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
Try this:
struct ColourRGB
{
ColourRGB(float Red=0, float Green=0, float Blue=0)
: Red(Red)
, Green(Green)
, Blue(Blue)
{
}
float Red;
float Green;
float Blue;
};
Steve
|
|
|
|
|
Now i never knew you could do that with variables. Unless your just making it up
My current favourite word is: PIE!
Good ol' pie, it's been a while.
|
|
|
|
|
|
Article was very good! Thanks for the link!
Priya Sundar
|
|
|
|
|
Ever noticed how there seems to be two sorts of selection behaviours in comboboxes? One sort makes you click and release the button before you can select items in the drop down list. The other allows you to click and drag the mouse, and will select on the mouse button up.
The default ones that appear in my MFC programs seem to be the first type, where you have to click twice to select something. Is there a way to make them into a click and drag type selection?
|
|
|
|
|
following code snippet works in VC++ 6
file = fopen((LPCTSTR)CSTRING_VARIABLE,"wb+")
but in VC 2005 above code can not compile because of CString and casting problem.
how I can convert above code to be compatible with visual C++ 2005.
Regards
Gut Mikh
|
|
|
|
|
What's the actual error?
Second, do you really need the explicit cast? What is CSTRING_VARIABLE?
You should be able to use a CString without the cast there, unless there's
a conflict with char/wchar_t types.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
fopen function need one const char * as its first parameter.
in visual C++ 6 we can cast a CString variable to a char* by using (LPCTSTR) .
but this simple methodology does not work for visual C++ 2005.
Because we want to upgrade one project from VC6 to VC2005, thus it is neccessary to change it.
Now I want a simple code snippet which converts a CString variable to char* .
Regards
Gut Mikh.
|
|
|
|
|
You shouldn't need the cast. CString has a cast operator that does this for you.
I'm still wondering what the actual compiler error is.
Gut Mikh Tappe wrote: we can cast a CString variable to a char* by using (LPCTSTR)
That's not a valid cast. LPCTSTR is a constant pointer to a TCHAR.
TCHAR can be a char or a wchar_t, depending on if _UNICODE is defined.
Without knowing the error message, I'm guessing your build settings are for unicode,
in which case you should either change the project settings to not use unicode, use the
correct CStringT type, or use _tfopen() instead of fopen().
Regardless, you should NOT need the cast. Casts should be used only when absolutely necessary,
because they can hide errors, exactly as demonstrated here.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I do agree with Mark's comment. When you create a new project in Visual C++ 2005, probably you might have not noticed the "Use Unicode Libraries" in the Wizard.
While you are dealing with these it's better to use tchar functions. You can get those functions just by including #include <tchar.h>
Please post the error code if possible.
-Sarath.
"Great hopes make everything great possible" - Benjamin Franklin
|
|
|
|
|
i do agree with Sarath.
when you change the charset in the project property sheet from "Use Unicode Libraries" to "Use MBCS Libraries",the compile problem with CString will disappear at once.
|
|
|
|
|
Try:
LPCSTR
Instead of LPCTSTR
|
|
|
|
|
Drop the casts. Use code like this:
#include <tchar.h>
file = _tfopen(CSTRING_VARIABLE, _T("wb+"));
Steve
|
|
|
|