Can't find out the error.
#include <iostream>
using namespace std;
struct node{
int id;
int *next;
};
node * get_data(int );
node * get_data(void);
void insert_node (node **, node **, node *);
void display_data(node *);
int main(){
node *head=0, *tail=0, *newPtr=0;
newPtr = get_data();
insert_node (&head,&tail,newPtr);
display_data (head);
return 0;
}
node * get_data(void){
node *newPtr = new node;
newPtr->id = 1;
newPtr->next = NULL;
return newPtr;
}
void insert_node (node **h, node **t, node *newPtr){
if (*h!=NULL && *t!=NULL){
newPtr = (*h)->next;
*h = newPtr;
}
else{
*h = newPtr;
*t = newPtr;
}
}
void display_data(node *p){
while (p!=NULL){
cout << p->id << endl;
p = p->next;
}
}