I'm trying to figure out why this 2d array is not outputting what I need it to. This program is inputting from two files. First problem is that the array is only showing the number of responses for answer "A" in all 5 columns. Second problem is that I need an "*" next to the correct answer. It is not doing it. PLEASE HELP! Here is my code:
The for loop at line 34 is making every 2nd dimension of "counter" the amount of letter 'A' answers.
Are you required to have a for loop there? It is confusing, I think if you wanted two for loops then the first one (line 28) needs to be inside this one.
I think this will work. Taking advantage of chars being numeric:
counter[i][responses[i] - 'A']++;
Here, if the response is 'A' then counter[i][0] gets increased ('A' == 65. 65 - 65 = 0). If the response is 'B', then counter[i][1] gets updated ('B' == 66, 66-65 = 1).
AWESOME! That helped get the correct numbers in the array. However, I still don't know how to get the "*" in the right place. See the last section in the code where I print the array.
For that loop you don't really care who said what, you only care about what the correct answer is. So, forget "responses", and focus on how to get the "*" in the right position depending upon what the answer actually is.