I can increment a FOR loop in xcode, but for some reason the reverse, namely decrementing, doesn't work.
This incrementing works fine, of course:
for (int i=0; i<10; ++i) {
NSLog(@"i =%d", i);
}
But, this decrementing doesn't produce a thing:
for (int i=10; i<0; --i) {
NSLog(@"i =%d", i);
}
I must have the syntax wrong, but I believe this is correct for Objective C++ in xcode.
I think you mean >
instead of <
:
for (int i = 10; i > 0; --i) {
If you want the values of i to be the same as in the original code except in reverse order (i.e. 9, 8, 7, ..., 1, 0) then you also need to change the boundaries:
for (int i = 9; i >= 0; --i) {
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With