from what you posted prelude, my problem is here:
Code:
...
while(Current->next != NULL)
{
...
}
...
it should be :
Code:
while(Current != NULL)
{
...
}
EDIT: hmmm.... that wasnt the problem.
here is my code btw.
Code:
#include <stdio.h>
#include <iostream>
using namespace std;
struct node
{
int data;
node *next;
};
void Push(node** head,node* new_node)
{
new_node->next = *head;
*head = new_node;
};
void display(node* head)
{
node *current;
current = head;
while (current != NULL)
{
cout << current->data << endl;
current = current->next;
}
};
int main()
{
node* head = new node;
node* item = new node;
head->next= NULL;
item->data = 5;
Push(&head,item);
item->data = 8;
Push(&head,item);
display(head);
return 0;
};