samedi 1 août 2015

what happens when increment counter and test counter are interchanged in for-loop syntax?

please explain why

int main()
{
    int i;
    for(i=1;i++;i<100)
    printf("%d",i);
    return 0;
}

results in infinite loop, whereas

int main()
{
    int i;
    for(i=0;i++;i<100)
    printf("%d",i);
    return 0;
}

doesn't run the loop even once? Please clarify how to interpret this kind of syntax?

Aucun commentaire:

Enregistrer un commentaire