Hi,
There are quite a few problems I can see:
The implementation of the container (linked list) should be separate from the data it stores. Normally there is a
struct
for the linked list, and one for a Node which holds a data item.
The linked list should have at least functions for
push
and
pop
and
print
. It is much more tidy and less error prone if you can call these functions. Also have a separate function to get and validate input. For example get all the the info for a student and validate it with a function, then push the whole thing onto the end of the list with one function call.
The linked list
struct
should also have a separate pointer for the
head
of the list. That way you can always start at the beginning of the list, and not with a moving target like
top
You are leaking memory: using
new
without
delete
Is there a reason why you are taking a C approach by having char arrays and using C functions like
strcpy
? Maybe your assignment requires it for some mad reason? Things are much easier if you can use
std::string
1) when I use the displayStudentNames function, the names are being printed in reverse order from what I put in |
Did you implement a stack rather than a list?
Any way see how you go :+) There are plenty of people to help, I am sure we all look forward to seeing your new code :+)