I have a small problem with adding some items to my linked list....the code compiles with no errors but when run it doesnt complete...it looks like it is still waiting for some input but i dont know where my loops are going wrong..
#include <iostream>
using namespace std;
struct details
{
int prod_id;
//int prod_code;
details *link;
};
typedef details* detailsPtr;
const int S=3;
void insert_head(detailsPtr& head, int id);
void insert_end();
void delete_head();
void delete_end();
void display(detailsPtr& head,int id);
int main()
{
int id, i;
detailsPtr head;
int j=1;
for (i=0;i<S;i++)
{
cout<<"Enter product ID "<<j<<": ";
cin>>id;
insert_head(head,id);
j++;
// cout<<endl;
}
display(head, id);
return 0;
}
void insert_head(detailsPtr& head, int id)
{
detailsPtr tmp_ptr;
tmp_ptr = new details;
tmp_ptr ->prod_id = id;
tmp_ptr -> link = head;
head = tmp_ptr;
}
void display(detailsPtr& head,int id)
{
detailsPtr disp;
disp = head;
while(disp!=NULL)
{
cout << "ID: ";
cout << disp->prod_id<<endl;
disp=disp->link;
}
}