Hi, everyone. I want to conditionally increment a value within a for loop, like this:
Code:
for (attempt = 1; attempt <= uinumberofattempts || h->prefs.persevere;
if (attempt) attempt++)
However, using a statement instead of an expression is not allowed. This is what I've come up with. Is this acceptable or hacky? The voids are necessary to suppress clang compiler warnings about unused values.
Code:
for (attempt = 1; attempt <= uinumberofattempts || h->prefs.persevere;
attempt ? (void) attempt++ : (void) 0)