flag2 is defined as an int. When a match is found in the for loop you assign the int loop variable c to flag2. So far so good, but when you use flag2 in the switch you try to match it with a char
c = "A";
c = 'B';
The code section above has another problem because for some cases you try to assign a pointer to a constant char ("A") to a byte. Put that mistake right and change the cases to ints rather than chars.