void Display(Productptr t)
{
    Productptr g;
    g=t;
    if(t==NULL)
        cout<<"The list is empty."<<endl;
    else
    {
    cout<<"Code\tDescription\tPrice\n";
    cout<<"====\t===========\t=====\n";
        while(g!= NULL)
        {       
            cout<<g->code<<"\t"
                <<g->description<<"\t\t"
                <<g->price<<endl;
        }
        cout<<"End of the list"<<endl;
    }
    system("pause");
}

This code give me problem.
When I show 1st time is ok.
After 1st time I add something or delete something it will shown repeated 1st node that I insert.After that I cannot get back the normal already.
Any one can explain and solve it??
Text file I also get the same problem.
When I add or delete something in function cannot work normal agian.
The picture down show my problem.

The loop that begins on line 11 of the code you posted: where in that loop do you increment g to point to the next node in the linked list? Don't you want something like this?

while(g != NULL)
{
  ... <snip>
   g = g->next;
}

Also I don't see any need to save the original parameter pointer because it is never used again in that function. You could just delete g and use t instead.

I solve my problem already.
Thank you.
I miss up one g=g->Next;
so i alway get back the samething.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.