i want to know whats the error over here. i just want to store the three value in a node and making a linked list but after storing two nodes that is headptr and than temptr, when the third node is made it stops.
I think my error is somewhere in "while loop" bt i couldnt find it.

node* addnode(int x, int r,int c)// x = value,r = row, c = coloumn
		node* nodeptr = new node;
		node* temptr;
		temptr = headptr;
		nodeptr->val = x;;
		nodeptr->rowval = r;
		nodeptr->colval = c;
	    nodeptr->next = NULL;
		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;
			 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;

Your statement

temptr->next = temptr;

should probably be

temptr = temptr->next;

There may be other problems, but this is a good place to start.

That said, I would like to suggest that you learn how to use code tags properly.

This question has already been answered. Start a new discussion instead.