Тема: Стек, need some help!!
Ситуація наступна: сказали нам вивчити самостійно дії з стеками, викладача дав нам наступний код як приклад, тільки вот, він не працює, підкажіть будь ласка в чому тут помилка, а ще якщо можна посилання на статтю пов'язану з даною темою(перелазив десятки статей і не знайшов якоїсь толкової).
[code=C++]
#include "stdafx.h"
#include "stdio.h"
#include "string.h"
#include "iostream"
#include "stdlib.h"
#include "conio.h"
struct MAN {
    char Surname[15];
};
struct {
    struct MAN M;
    struct STACK *next;
};
void sorting(struct STACK **head);
void add(struct STACK**head);
void іnput(struct MAN *w);
void display(struct STACK *wk);
using namespace std;
void main(void)
{
    struct STACK *head = NULL;
    while(1) {
        cout << "Operations: " << endl;
        cout << "a - Add" << endl << "d - Display" << endl << "s - sort" << endl;
        switch(getch()) {
            case 'a': case 'A': add(&head); break;
            case 'd': case 'D': display(head); break;
            case 's': case 'S': sorting(&head); break;
            default:cout << "Error" << endl << "Try again" << endl;
        }
        cout << "Press any key" << endl;
        getch();
    }
}
void іnput(MAN *w)
{
    cout << "Enter your surname: ";
    cin >> w->Surname;
}
void display(STACK *h)
{
    cout << "Information:" << endl;
    if(!h) {
        cout << "STACK is empty";
        return;
    }
    do {
        print(h); h = h->next;
    } while(h);
    return;
}
void sorting(STACK **head)
{
    struct STACK *cur;
    struct STACK *s;
    struct STACK *p;
    struct STACK *pr;
    if(!*head)
    {
        cout << " Stack is empty" << endl;
        return;
    }
    cur = *head;
    while(cur->next)
    {
        s = cur->next;
        pr = cur;
        while(s) {
            if(strcmp(cur->M.Surname, s->M.Surname) <= 0) {
                pr = s;
                s = s->next;
            }
            else {
                if(cur == *head) {
                    *head = s;
                    pr->next = s->next;
                    s->next = cur;
                }
                else {
                    p->next = s;
                    pr->next = s->next;
                    s->next = cur;
                }
                cur = s;
                s = pr->next;
            }
        }
        p = cur;
        cur = cur->next;
    }
    cout << "Sorting is over" << endl;
    return;
}
void add(STACK **head)
{
    struct STACK *tmp;
    struct MAN W;
    іnput(&W);
    tmp->M = W;
    tmp->next = (*head);
    (*head) = tmp;
    return;
}
[/code]