I'd suggest reading my post again, but since I'm already typing a response might as well say it again. If you have a variable, an integer, then you can use it to determine which character to change. You know how you are changing the 0 character using [0]. You can change the 1 character with [1]. But, if you create an integer variable, you can use [var], and change var to whatever you want. In your case, you want it to start at 0, and each character you input, you increase by 1. That way the first character is [0], the second will be [1], and so on. But, all you need to do is have [var] and make sure to increase it.
Looking at your code though, a lot of those ifs aren't necessary. You can use the ordering of ASCII to your advantage, but I'll skip that and just show you the ternary operator.
- Code: Select all
Name[0] = (lettercase==0) ? 'a' : 'A' ;
It uses the form, (condition ? do this : else do this). So, if the condition is true, it will execute the first bit (before the colon), but if it is false, it will return the second. So the above code will set Name[0] to a if lettercase is 0, otherwise it sets it to A.