This is not an exercise for a beginner, so I assume you have some experience.
This site[
^] should prove helpful, because it covers both the C++ and C libraries.
Each
#include
is from the C++ STL, so you need to make the code work after removing them. You therefore need C equivalents of
iostream
,
stack
,
list
, and (for allocating memory)
new
.
The C equivalent of
iostream
is
stdio.h
, where you need to find replacements for
cin
and
cout
.
The C equivalent of
new
is
malloc
. The original code doesn't bother to
delete[]
the arrays that it allocates, but the C equivalent for that is
free
if you want to add it as an enhancement.
You should have enough experience to implement a stack and a list (a two-way linked list). Your stack needs to support the functions
empty
,
top
,
push
, and
pop
. Your list needs to support the functions
push_back
,
begin
, and
end
. Curiously, the original code could have used
vector
, which also supports those functions but is simpler (just a dynamically expandable array).
I see nothing that is specific to any operating system, so your code should work fine on Linux, Windows, or wherever once you've completed the work just outlined.