char RED[2]={
'1','2'}; // our secret (!) number
void checkPIN()
{
if (attemptC[0]==RED[0]&&
attemptC[1]==RED[1])
{
correctPIN();
}
else
{
incorrectPIN();
}
if (attemptC[0]==YELLOW[0]&&
attemptC[1]==YELLOW[1])
Two letter codes are not exactly secure. Think how ugly this is going to look when you start using 8 letter codes.
You could properly define RED:
char RED[] = "12345678";
Then, properly store the key in attemptC:
default:
attemptC[z] = key;
z++;
attemptC[z] = '\0';
Then, use strcmp() to do the comparison(s):
if(strcmp(RED, attemptC) == 0)
// red match
else if(strcmp(YELLOW, attemptC) == 0)
// yellow match