I can not do a swap operation while sorting. It crashes when I do it. Why? : <pre><code>struct Dates
{
    int day;
    int month;
    int year;
}accountinfo[3];

struct Accounts
{
    string name,lastname;
    int number;
    float balance;
}account[3];

void sortduetoaccnumbers()
{
    for (i=0;i&lt;3;i++)
    {
        for (j=0;j&lt;3;j++)
        {
            if (account[j].number&gt;account[j+1].number)
            {
                //swap
            }
        }
    }
}
void sortduetodates()
{
    for (i=0;i&lt;3;i++)
    {
        for (j=0;j&lt;3;j++)
        {
            if (accountinfo[j].year&gt;accountinfo[j+1].year)
            {
                //swap
            }
            else if (accountinfo[j].year==accountinfo[j+1].year)
            {
                if (accountinfo[j].month&gt;accountinfo[j+1].month)
                {
                    //swap
                }
                else if (accountinfo[j].month==accountinfo[j+1].month)
                {
                    if (accountinfo[j].day&gt;accountinfo[j+1].day)
                    {
                        //swap
                    }
                }
             }
        }
    }
}
</code></pre>

<p>I can not sort these accounts using sorting algorithms. It crashes if I enter them. cmd stops suddenly and finishes the program.</p>

<p>I entered a comment line where swapping functions have to go. So you can analyze the code.</p>

<p>Every other functions are working except this one. I'm stuck at this point.</p>
