doublylinkedlist class

Hello, this is the part of my program that displays. I'm getting a runtime error during the while loop when ptr gets to be NULL. I can't see any reasons. I've checked the list if the it tries to point the next node while the ptr = NULL, but that doesn't seem to be the case.

Here's the error that I got;

Unhandled exception at 0x00407206 in project1.exe: 0xC0000005: Access violation reading location 0x00000014.

and then it shows xstring line 1733 which is the 3rd line here;

size_type size() const _NOEXCEPT
		{	// return length of sequence
		return (this->_Mysize);

Any help appreciated, thanks!
Last edited on
This is an excellent problem to solve using a debugger. You can use it to step through your program and see what values are as it progresses, instead of just when an error occurs. Have you ever used one before? If not, I highly recommend learning.
Well I actually understood that the problem is in while loop by debugging. But I can't see anything wrong in the list or in the elements of the list, and that's why I tried here.


switching the places of course != ptr->courseName and ptr != NULL seems to be working because now it first checks if the ptr is equal to NULL and then tries to read it's element. And if it's NULL it doesn't try reading it.

while(ptr != NULL && course != ptr->courseName)
Last edited on
Topic archived. No new replies allowed.