|
Hi,
Is there any macro or some thing to avoid memory leak.I am finding problems with linked lists.
I have 10-12 lists and these are causing(actually my code )during relase.
It not only crashes the program but also the OS.
How to check where exactly is the problem without crashing the program and eventually windows itself.
thanks
|
|
|
|
|
Try using debugger walking your code step by step.
You could also try using BoundsChecker program to catch memory leaks.
Miroslav Rajcic
|
|
|
|
|
Use _CrtDumpMemoryLeaks().
These leaks can be seen in after using the debugger and exiting the
program(Your exit, not stopping the dbgr).
Then follow the addresses.
#include <crtdbg.h>
Joy...
--Bar Cochva--
|
|
|
|
|
Hello there,
Someone please tell me which are the minimal places in the registry where I should add an ODBC entry.
It would help if someone tells the minimal entries too.
Thanx
|
|
|
|
|
use SQLConfigureDataSource(...)
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
can someone please help me with this piece of code. i was at work and bored so i started writing this. It should generate 9999 random numbers and count how many times it was 5 (according to me anyways). i'm really confused because i've programmed some heavy stuff already in MFC and i just dont get this. The problem is that v turns out to be 75536 every time i run it...
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <windows.h>
int main(int argc, char *argv[])
{
srand((unsigned)time(NULL));
int i;
int v;
for (i=0;i<=9999;i++)
{
int a = rand()%(9-0);
cout << a;
if(a=5)
{
v = v+1;
}
}
cout << "\n";
cout << "\n";
cout << "The number of times 5 was generated:";
cout << v;
cout << " / 9999\n";
getch();
return 0;
}
Thankya
Kuni
|
|
|
|
|
ok the includes are:
stdio.h
iostream.h
conio.h
stdlib.h
time.h
(yes there was one include too many :p)
kuni
|
|
|
|
|
ok the includes are:
stdio.h
iostream.h
conio.h
stdlib.h
time.h
(yes there was one include too many :p)
kuni
|
|
|
|
|
if (a=5)
Shouldn't that be if (a==5) ?
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
no i tried that before, it gives something even more odd, v becomes negative....
kuni
|
|
|
|
|
Perhaps you should initialize v variable at the start of the program
int v = 0;
Miroslav Rajcic
http://www.spacetide.com
|
|
|
|
|
lol i just figured that out thx anyways
|
|
|
|
|
Also, you never initialize v to be 0 -- probably explains why v is always 75536.
|
|
|
|
|
|
Can someone give me some tips on programming the systems control panels in code. Specifically the display control panel.
Thanks.
|
|
|
|
|
use the platform SDK version
|
|
|
|
|
I'm creating a program from which the user pick an item from a dropdown combo box then depend on what it is, display a short description in a text edit field, how can this be done? I'm pretty familar with the variables and classes and stuff, just need a way to do this... Please help.
|
|
|
|
|
You need to use the CCombobox::GetItemData() method.
But you first need to add the strings in the ComboBox and Set the Itemdata of each string. For this you have the CComboBox::SetItemData.
When the user pick in the combox you can get the ItemData and with this value you can search for a associated string with that value.
Good Luck!!!!
Carlos Antollini.
|
|
|
|
|
I'm trying to use the function AVISave, which takes as a parameter a callback function:
AVISAVECALLBACK lpfnCallback
with the prototype:
LONG PASCAL SaveCallback(int nPercent)
When it comes to passing a function to another function, we leave the realm of any C++ that I understand. How do I call AVISave? And, where does the "Pascal" come from?
thanks,
Jake
|
|
|
|
|
I don't know the prototype for AVISave, but this is the general idea:
LONG PASCAL SaveCallback(int nPercent)
{
UpdateProgress(nPercent);
}
void SaveAVIFile()
{
AVISave(SaveCallback, );
}
So really, in essence, you just treat the function as a variable.
Hope that helps,
> Andrew.
|
|
|
|
|
This is what my code looks like, where AVISave takes a callback function as 3rd arg:
long PASCAL CBadClass::SaveCallback(int percent)
{
return AVIERR_OK;
}
...
bool CBadClass::Foo()
{
AVISave(...,SaveCallback, ...);
}
This gives me the compilation error:
error C2664: 'AVISaveA' : cannot convert parameter 3 from
'long (int)' to 'int (__stdcall *)(int)'
None of the functions with this name in scope match the target type
needless to say, I've got no ideas here
thanks,
Jake
|
|
|
|
|
|
The ForumFAQ article has tons of good stuff, including telling me to make my callback function global or static, however I've tried it with each and still get the exact same error as before (see previous message). So, something else is killing me, I guess...any more ideas?
thanks,
Jake
|
|
|
|
|
Your member function doesn't have the required prototype. It's
long PASCAL CBadClass::SaveCallback(int percent) but AVISAVECALLBACK is defined as
typedef BOOL (FAR PASCAL * AVISAVECALLBACK)(int); Change the return type of your function to BOOL. And BTW, FAR is obsolete and can be ignored, and PASCAL has been replaced by CALLBACK in Win32.
--Mike--
http://home.inreach.com/mdunn/
"Make sure that if you are using a blow torch that you don't set anything on fire."
-- Chris Maunder
|
|
|
|
|
Well, for starters the parameter is a pointer to the callback function, so you might try &SaveCallback.
Christian
Secrets of a happy marriage #27:
Never go to bed if you are mad at each other. It's more fun to stay up and fight.
|
|
|
|