I'm using scanf to scan for simple user input (see below for an example of what I'm doing...), and if I try to use it multiple times to scan for a character, it ignores any try after the first. I have a feeling this has to do with the stdin not being cleared after the input, and it just reads the first input over again, but I have no idea how to fix this. I've read through the explanations of scanf on this and other websites and am still confused.
I want to first figure this out before I move on to trying cin. I think knowing why this isn't working would be very helpful to my understanding of C/C++ as a whole...
The solution to your Problem is actually quite simple.
when u enter a key (or more than one) and press enter you read 2 (or more than 2) characters. Your characters + 1 newline.
Use for example " %c" (as many whitspaces as u want + character) instead of "%c" and u shouldn't have any problems any more.
Well, that certainly fixed the problem, but I'm still not certain I understand why. Is it that when I use "%c" it only wants to read 1 character, but by default when I enter "T" and press enter, there are two characters, and the next scanf is thrown off because of that?
scanf("%c", &Ans[0]); // input ABCDE reads A
scanf("%c", &Ans[1]); // reads B
scanf("%c", &Ans[2]); // reads C
scanf("%c", &Ans[3]); // reads D
scanf("%c", &Ans[4]); // reads E
scanf("%c", &Ans[5]); // reads \n
scanf("%c", &Ans[6]); // wait for new input
You may want to have a look at getch() (POSIX) or _getch() of the conio.h header file.
Or maybe later _kbhit() for a little more complex usage of console input.