I am a little confused why this is not working:
id = (isChar ? (id + 1 > 122 ? 65 : id++) : id++);
The input here can either be an int or a char converted to an INT. I am then incrementing the id and increasing either the int or char. The problem is, when I input a char, the number does not seem to change?
Change
id++toid + 1in both cases. You are throwing away the change from the increment in the assignment, which is executed last.As a general rule, avoid side-effects (such as
++) in complex expressions. They make the whole expression intractable. This has tripped you up here.Better yet, increment
idbeforehand since you always seem to increment it:or