reverse linked list

I have to reverse a linked list using a stack and then print it, but having problems with it.

It would be great if I can get any hint from anybody.

Thank you.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
void reverseUsingStack (nodeType *first)

{
 
    int n=0;
    nodeType *temp;
    temp = first;
    StackADT <int> stack;
    while (temp !=NULL)
    {   
          stack.Push (temp->info);
          temp= temp ->link;
   
    }
 }

void printList (nodeType *first)
{

    if (first  != NULL)
        {
            cout << first ->info << " " << endl;
            printList (first->link);
           
        }
check the algorithms library for something that would do this.
Topic archived. No new replies allowed.