Warning: Long, and probably difficult to follow.

Nodes not getting deleted, causing failure

Posted 15 December 2009 - 01:28 AM

Hello.
So, my final assignment for my C++ class: Take a regular equation, input it one character or value at a time, then move it through several functions.
Flowchart:
-Prepares a doubly linked list
-Sets left paran
-Reads in equation piece by piece - if piece is an operator (+, -, *, /, (, ) ) then this gets set to oper of that struct portion; otherwise, it gets set to value.
-Goes to head of equation
-Finds a right paran, sets RP to it
-Goes backward until left is found, sets LP to it
-Sends it into functions which multiply, divide, add, and subtract whenever those things are found
-Deletes parans
-If there are any more parans, runs from step 2.

I always have warnings enabled...I didn't see most of those.
I'm not sure which point the multi-character constant is referring to (don't have a complier atm) but I know the rest.
-My instructor wanted us to use void
-The comparison is supposed to be always true. However, it's not true when it runs into junk data at the end of the list, and that part works fine.
-The last two are just variables I keep fogetting to delete. I don't use them at all. I'll delete them.

EDIT:
Changing the for loop made the program run flawlessly. Thanks a bunch!

Re: Nodes not getting deleted, causing failure

You might want to print the info linked to here and anonymously leave a copy on your instructor's desk.

If they are going to take salary as a teacher they shouldn't be passing on bad habits that your classmates will later need to unlearn

"void main()" is wrong. Always use "int main()".
Read here the words of the man who invented C++:http://www.research.....html#void-mainCan I write "void main()"?
The definition
void main() { /* ... */ }
is not and never has been C++, nor has it ever been C. See the ISO C++ standard 3.6.1[2] or the ISO C standard 5.1.2.2.1.