vendredi 26 octobre 2018

C++ - For loop not executed

I don't understand why this for loop works

void managingTable(unsigned char table[256][256][1])
{
    for (unsigned int x = 0; x <= 255; x++)
    {
        for (unsigned int y = 0; y <= 255; y++)
        {
            doSomethingWithTable();
        }
    }
}

and this doesn't work exiting when y reaches 255 but with no iteration on x that remains 0

void managingTable(unsigned char table[256][256][1])
{
    unsigned int x = 0;
    unsigned int y = 0;

    for (x; x <= 255; x++)
    {
        for (y; y <= 255; y++)
        {
            doSomethingWithTable();
        }
    }
}

Also this doesn't work:

void managingTable(unsigned char table[256][256][1])
{
    unsigned int x = 0;
    unsigned int y = 0;

    for ( ; x <= 255; x++)
    {
        for ( ; y <= 255; y++)
        {
            doSomethingWithTable();
        }
    }
}

Aucun commentaire:

Enregistrer un commentaire