Hi everyone,
I’m beginner and I need a little help. I have to make RPN (postfix) calculator using stack which is implemented by singly linked list in C. Now I found that but in C++ and I’m having trouble translating it to C. Can you help me getting things to work? I have started from http://www.mediafire.com/view/q833x5sic8eq4sx/from_c__.txt and using a little code from http://www.mediafire.com/view/ewz9so6999ig5x0/using_c.txt I get to http://www.mediafire.com/view/qesca0cg0vzjzac/to_this_in_c.txt code and it debugs but when I enter anything in console it crashes and gives me some assembly code I’m using VS C++ 2010. Please help me to fix this, I can’t find what’s wrong.

So, you are using other people's code? Have you tried implementing it yourself? Do that, and we can help you. Also, you will learn a lot more about what you are doing. An RPN calculator is effectively a stack machine. You can use the singly-linked list pattern in either C or C++. C++ also has stack constructs in the STL that you can use (push/pop data).

I'm trying to implement it myself have you looked all the code? I can use only C, no STL no constructors, no preimplemented functions, nothing that c++ has!!

Edited 1 Year Ago by alexx006

Then a singly-linked list where you insert at the top of the list (push), and remove from there as well (pop), will give you a nice stack behavior. You can use an array as well, inserting and removing from the bottom of the array. Either will work, though the array is moderately more efficient. I have used both methods in the past for very similar problems, including an RPN calculator! My best (but most difficult) implementation was done using a B-Tree structure, but that was for an infix calculator. :-)

Anyway, this may help: https://www.gnu.org/software/bison/manual/html_node/RPN-Calc.html

If you cannot use any C++ STL container, then what's the point of using c++ ?
I would prefer vector insead of link list in c++

This article has been dead for over six months. Start a new discussion instead.