mercredi 20 février 2019

Meaning of i = i++ [duplicate]

This question already has an answer here:

Recently I came up with the following chunk of code

int main()
{
  for(int i=1;i<5;i=i++)
  {
     cout<<i;
  }
} 

When it is executed, it prints 1 infinite times (infinite loop). I didn't get it how did it happen? What does the statement i=i++ does that the value of i never increases?

Aucun commentaire:

Enregistrer un commentaire