this code only makes two nodes and at the time of making third node it stucks
Code:
void addnode(int x, int r,int c)//+++++++++++++++++++++++++++++=addnode
{
node* nodeptr = new node;
node* temptr;
temptr = headptr;
nodeptr->val = x;;
nodeptr->rowval = r;
nodeptr->colval = c;
nodeptr->next = NULL;
cout<<"nodeprtr->value"<<nodeptr->val<<endl;
cout<<"nodeptr->row"<<nodeptr->rowval<<endl;
cout<<"nodeptr->col"<<nodeptr->colval<<endl;
if ( headptr == NULL )
{
headptr = nodeptr;
cout<<"headptr->value"<<" "<<headptr->val<<endl;
cout<<"headptr->row"<<" "<<headptr->rowval<<endl;
cout<<"headptr->col"<<" "<<headptr->colval<<endl;
// return headptr;
}
else
{
if (headptr != NULL )
{
while(temptr->next!= NULL )
{
temptr->next = temptr;
}
}
temptr->next = nodeptr;
temptr = nodeptr;
cout<<"temptr->val"<<" "<<temptr->val<<endl;
cout<<"temptr->rowval"<<" "<<temptr->rowval<<endl;
cout<<"temptr->colval"<<" "<<temptr->colval<<endl;
//return nodeptr;
}
}