insert function is doesn't add a new elements : <p>I wrote a program which should to insert elements in the list compare with their costs, but it doesn't work. I enter one element and then program doesn't work. And I can't understand what's wrong.</p>

<p>here is an exactly the exercise:</p>

<h2>Modify the list, so elements on the list are ordered by price. New items added to the list should be inserted into the right place</h2>

<pre><code>   #include &lt;iostream&gt;
#include &lt;string&gt;

using namespace std;

typedef struct listt
{
    string name;
    float price;
    struct listt *next;
}listt;

typedef listt* listPtr;

void insertt(listPtr *, string, float);
void printList(listPtr);
void instruct();

int main()
{
    unsigned int choice;
    float costs;
    string itemName;

    listPtr head = NULL;

    instruct();
    cin &gt;&gt; choice;

    while(choice != 3)
    {
        switch(choice)
        {
        case 1:
            cout &lt;&lt; "Please enter the name of the item:" &lt;&lt; endl;
            cin &gt;&gt; itemName;
            cout &lt;&lt; "Please enter the cost of item: " &lt;&lt;endl;
            cin &gt;&gt; costs;
            insertt(&amp;head, itemName, costs);
            break;
        case 2:
            printList(head);
            break;
        }
        cout&lt;&lt;"Choose the operation\n";
        cin &gt;&gt; choice;
    }

    cout&lt;&lt;"end of operation";
    return 0;
}

void instruct(void)
{
    cout&lt;&lt;"Choose the operation\n" &lt;&lt; "1.Fill the list\n" &lt;&lt; "2.Print the list\n" &lt;&lt; "3.End operation\n";
}

void insertt(listPtr *itemList, string nm, float cst)
{

    listPtr previousPt;
    listPtr currentPt;
    listPtr newPtr;

if(newPtr != NULL){
    newPtr-&gt;name = nm;
    newPtr-&gt;price = cst;
    newPtr-&gt;next = *itemList;
}

    previousPt = NULL;
    currentPt = *itemList;

    while(currentPt != NULL &amp;&amp; cst &gt; currentPt-&gt;price )
    {
        previousPt = currentPt;
        currentPt = currentPt-&gt;next;
    }

    if(currentPt == NULL)
    {
        newPtr-&gt;next = *itemList;
        *itemList = newPtr;
    } else{
    previousPt-&gt;next = newPtr;
    newPtr-&gt;next = currentPt;
    }
}

void printList(listPtr hh)
{
    while(hh-&gt;next != NULL)
    {
        cout &lt;&lt; hh-&gt;name &lt;&lt;" " &lt;&lt; hh-&gt;price&lt;&lt; endl;
        hh = hh-&gt;next;
    }
}
</code></pre>
