This question already has an answer here:
- Undefined behavior and sequence points 5 answers
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