|
Thanks DavidCrow,
It works! Cool!
regards,
George
|
|
|
|
|
I have the following code to read data from a list of files. The code read the first file and read the data correctly. I used break point debug and found at "fclose(f_ptr2)" giving error: "Access Violation"
//
FILE *f_ptr2;
//
//
for (int ii=0;ii
|
|
|
|
|
Review and correct your post: the for loop can't be properly seen and some indentation wouldn't hurt either.
Steve
|
|
|
|
|
Also, do you check the return value from fopen()?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am using SetupDiGetClassDevs() API to retrieve some information related to Battery, but while using "GUID_DEVICE_BATTERY" macro, Visual Studio 8 gives linker error that "unresolved external symbol _GUID_DEVICE_BATTERY".
What could be reason for this?
I have verified for appropriate libraries.
Whenever I build this project in VC++ 6.0, it gets build successfully.
|
|
|
|
|
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.
|
|
|
|