Doesn't increment.Code:int i; void loop() { i=i++; Serial.println(i); delay(1000); }
Ard. 1.8.5/ Td1.48
Doesn't increment.Code:int i; void loop() { i=i++; Serial.println(i); delay(1000); }
Ard. 1.8.5/ Td1.48
That is correct. i++ is a post increment operator. I.e. it increments after the assignment. If you use ++i it should work.
Anyway, you probably meant i++, instead of the unusual i = i++; ?
Edit: actually it is undefined behaviour. (see https://stackoverflow.com/a/949443/1842762)
Right. Bone-head
I knew it works with locals but that's 'cause I use correctly there.
What would be the reasoning behind using i=i++ as opposed to just i++? For pointers I understand the difference, but I’m lost as far as regular variables go.
Bone-head is the reason... I should think a bit before posting