show the popped element in c++?
<p>I have problem at the last part of this program. How can I display the element that have been popped?</p>

<p>I try to change the looping, but cannot..</p>

<pre><code>#include&lt;iostream.h&gt;
typedef struct TINDANAN
{
    int atas;
    char senarai[4];
} tindanan;

void cipta(tindanan *t);
void push(tindanan *t);
void pop(tindanan *t);
int penuh(tindanan *t);
int kosong(tindanan *t);

void main()
{
    int pilihan,jawapan,i;
    tindanan t;
    cipta(&amp;t);
    cout&lt;&lt;"\n1-&gt;Push\t\n 2-&gt;Pop \t\n 3-&gt; Keluar \n pilihan =";
    cin&gt;&gt;pilihan;
    while(pilihan !=3)
    {
        switch (pilihan)
        {
            case 1: push(&amp;t);
                break;
            case 2: pop(&amp;t);
                break;
            default : cout&lt;&lt;"\nTidak Sah";
        }
        cout&lt;&lt;"\n1-&gt;Push\t\n 2-&gt;Pop \t\n 3-&gt; Keluar \n pilihan =";
        cin&gt;&gt;pilihan;
    }
}

void cipta (tindanan *t)
{
    t-&gt;atas =-1;
}

int penuh (tindanan *t)
{
    if (t-&gt;atas ==3)
        return (1);
    else
        return (0);
}

void push (tindanan *t)
{
    int i;
    char data;
    if (penuh(t) ==1)
        cout&lt;&lt;"\nTindanan Penuh\n";
    else
    {
        cout&lt;&lt;"\nHuruf Character: ";
        cin&gt;&gt;data;
        t-&gt;atas++;
        t-&gt;senarai[t-&gt;atas]=data;
        cout&lt;&lt;"\nKandungan Timbunan :\nIndex | Data\n";
        for(i=t-&gt;atas;i&gt;-1;i--)
            cout&lt;&lt;"| "&lt;&lt;i&lt;&lt; " | "&lt;&lt; t-&gt;senarai[i];
    }
    cout&lt;&lt;"\n";
}

int kosong (tindanan *t)
{
    if (t-&gt;atas ==-1)
        return (1);
    else
        return (0);
}

void pop (tindanan *t)
{
    int i;
    if(kosong(t) == 1)
        cout&lt;&lt;"\nTindanan Kosong\n";
    else
    {
        t-&gt;atas--;
        cout&lt;&lt;"\nkandungan Timbunan :\nIndex | data\n";
        for(i=t-&gt;atas;i&gt;-1;i--)
            cout&lt;&lt;" | "&lt;&lt;i&lt;&lt; " | "&lt;&lt;( t-&gt;senarai[i]);
        cout&lt;&lt;"\nPop Item";
        for(i=3;i&gt;t-&gt;atas;i--)
            cout&lt;&lt;"| "&lt;&lt;i&lt;&lt; " | "&lt;&lt; t-&gt;senarai[i];
    }
}
</code></pre>

<p>Sorry I'm just learn c++ this year.</p>
