I keep running across "i++" in the code and don't really understand the significance. Could you tell me what this means?
it is short hand for i = i + 1;
One thing to note is that there is a difference between ++i and i++. The first on increments i BEFORE it is use in an expression. The second one increments i AFTER it is used.
int i = 5;
int a = ++i; // a = 6, i = 6
int b = i++; // b = 6, i = 7
int c = i; // c = 7
int d = --i; // d = 6, i = 6
int e = i--; // e = 6, i = 5
int f = i; // f = 5
I'm pretty sure they were created to take advantage of the auto-increment/decrement registers of the PDP-11 and other early Digital Equipment Corporation minicomputers.
i++ ... increments i AFTER it is used
In particular, an expression like: Serial.print(myarray[i++]);will access the i'th element of the array and then increment i to index the NEXT element.
While were talking about short cuts:
this:
int send = 0;
send +=1;
is equivalent to:
int send = 0
send = send + 1;
This type of writing can be used with different operations (+, -,*, &, |, etc, etc...) and with different values. not only to increment by 1 but by any value you please.
The fancy term for i++ is "postincrement" and for ++i, preincrement. Be careful with these, they can be a cause of insidious bugs, especially for a beginning programmer.
Another example is C++ but this does not equivalent to C=C+1, so if teacher asked you to define C++ then don't answer C=C+1.. So also see in that context 8)
I always thought it did
C++ equals C plus one hell of a lot of headers.