|
Hello!
Change your line in red to read:
<br />
PreviousNode = NULL;<br />
Then, below the while loop, add this code:
if(PreviousNode != NULL)
{
PreviousNode->Next = NewNode;
NewNode->Next = NodePtr;
}
else
{
NewNode->Next = NodePtr;
Head = NewNode;
}
I think this should fix your problem, because, right now, your application does not take into account the condition that the m_ssan being passed to the function is the lowest value in the list.
I didn't give this a try yet, but let me know if it works.
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Thanks Alexander, I just tried that however it is still puking. I am not sure why as this looks like it makes sense.
Nick Parker
May your glass be ever full.
May the roof over your head be always strong.
And may you be in heaven half an hour before the devil knows you’re dead. - Irish Blessing
|
|
|
|
|
Try to trace what you are doing!
If the statement "while (NodePtr != NULL && NodePtr->ssan < m_ssan)" is false ( NodePtr->ssan >= m_ssan )than PreviousNode is not set.
if m_ssan is a new maximum you only break if NotePtr->Next gets somewhere Null.
|
|
|
|
|
Hi all. I'm trying to create a simple stack template class. Yes, I can hear your remarks about just using the STL, but I have my reasons. Anyway, I'm simply trying to allocate memory to grow the stack array, but keep getting the same runtime error:
Unhandled exception at 0x0046a470 in StackTest.exe: 0xC0000005: Access violation reading location 0x00000000.
The call stack currently looks like this:
StackTest.exe!strlen() Line 78 Asm
StackTest.exe!exception::exception(const exception & that={...}) + 0x31 C++
StackTest.exe!std::bad_alloc::bad_alloc(const std::bad_alloc & __that={...}) + 0x13 C++
StackTest.exe!std::_Nomemory() Line 8 + 0xd C++
StackTest.exe!operator new(unsigned int size=240) Line 15 C++
StackTest.exe!operator new[](unsigned int count=240) Line 7 + 0x9 C++
StackTest.exe!CStack<int,30>::resize(unsigned int nNewSize=60) Line 75 + 0xc C++
StackTest.exe!CStack<int,30>::push(int & tData=8) Line 26 C++
StackTest.exe!main() Line 33 C++
StackTest.exe!mainCRTStartup() Line 259 + 0x19 C
kernel32.dll!GetCurrentDirectoryW() + 0x44
I assume from this information that there isn't enough memory available to make the allocation, but this is only the second new call that I make from the start of the program. Also, I'm only trying to allocate 240 bytes of data. Here's the code for the resize() function:
template < typename T, int INCREMENT ><br />
void CStack< T, INCREMENT >::resize( size_t nNewSize )<br />
{<BLOCKQUOTE>
if ( nNewSize == m_nCapacity )<br />
return;<br />
else if ( nNewSize < INCREMENT )<br />
nNewSize = INCREMENT;<br />
<br />
T *pNewStack;
size_t nMinSize;
<br />
nMinSize = nNewSize < m_nCapacity ? nNewSize : m_nCapacity;<br />
<br />
pNewStack = new T[ nNewSize ];<br />
<br />
memmove( pNewStack, m_pStack, nMinSize*sizeof(T) );<br />
<br />
delete [] m_pStack;<br />
<br />
m_pStack = pNewStack;</BLOCKQUOTE>}
Class Variables:
m_nCapacity = 30
m_nSize = 30
INCREMENT = 30
I appreciate any insite that anyone can provide. Thanks!
-Michael Anderson- 完成の円
|
|
|
|
|
|
I would doubt that you are out of memory unless you have a leak. You might be over running an allocated memory region and thus trashing the memory manager.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
hello,
is there a simple way, how different dialogues can be linked in a program?
lucky
|
|
|
|
|
Linked how ? Talk to one another ? I presume they are modeless ? They can just hold pointers to each other, provided by the host window. If that's not what you want, explain further what you're trying to do, so we can help.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
They can just hold pointers to each other
this i still have, when the first dialog is linked with the second dialog, everything is fine, but when the first is linked with the second and third dialog, the program is terminated.
what´s wrong?
lucky
|
|
|
|
|
Why do you have three dialogs up ?
Lucky2002 wrote:
what´s wrong?
1. It's probable that a pointer you're passing around is becoming invalid for some reason.
2. You haven't posted any code, which makes it hard to do more than guess.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
I believe that the first point is my problem.I think, I must give a value to the pointers (if they be produced). But how? (I´m sorry, but I have the code not here)
lucky
|
|
|
|
|
Unused pointers should always be set to NULL, and checked for NULL before use. Also, ::IsWindow will tell you if a pointer is a valid window ( which a dialog is ). Finally, show and hide your modeless dialogs so the pointer does not change, rather than destroying and recreating them.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
i am confused.
can you give me an example of it
(They can just hold pointers to each other, provided by the host window),
where also the pointers are adjusted to zero?
thank you very much
lucky
|
|
|
|
|
Lucky2002 wrote:
where also the pointers are adjusted to zero?
In the constructor.
MyDialog1::MyDialog1()
{
pDialog2 = NULL;
}
Then presumably the main window when it creates dialog2, also passes the pointer to dialog1. In dialog1, you do this
{
if (pDialog2 && ::IsWindow(pDialog2))
pDialog2->SomeMethod(nSomeInt);
}
Finally, when the main program wants to get rid of a window, it calls ShowWindow(SW_HIDE); and when it wants to show it does this
if (m_pDialog1)
m_pDialog1->ShowWindow(SW_SHOW);
else
{
// Create the dialog
}
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
thank you very much
lucky
p.s.: not confused anymore
|
|
|
|
|
Which libraries do I need to used TCP/IP protocal in Visual C++ 6.0?
|
|
|
|
|
What do you mean?
What lib-files?
Ws2_32.lib but you can read all about that in MSDN...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|
|
Do you use Winsock or Winsock2?
winsock.h
winsock2.h
ws2_32.lib
Kuphryn
|
|
|
|
|
Tip: You should probably use the WinSock 2 library. If so, include <winsock2.h> before including <windows.h>. That way, it won't use the WinSock 1 definitions, besides, it in turn includes <windows.h> itself.
Don't forget to add ws2_32.lib to your imports in your settings so your app will link to the dll imports.
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
Anyone knows how to create a CArray of complex numbers? Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
CArray<std::complex<double>,std::complex<double>&> array;
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks.
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
In complex number class, can I be able to just change the value Real or Imaginary?
mIchAel Liu
__________________________________________________________
The secret of business is to know something that nobody else knows.
|
|
|
|
|
No, you can't directly change the parts. You must use an assignment, e.g.
std::complex<double> c(1.0, 2.0);
...
c = std::complex<double>(c.real(), 3.7);
|
|
|
|
|
Hi
I'm writing COM add-in to MsProject2000. The problem is that using Project object I cannot change cursor that appear in MsProject app. I tried to change the cursor by WinAPI (unfortunately in this case CWaitCursor can't be used) calls but I failed. Is this possible to change cursor in MsProject by executing some code from my add-in?
Mariusz Popiolek
|
|
|
|