Hi. I'm trying to write a simple program where you need a key to open a door, and it requires you to get the key before opening the door. I'm getting some errors. This is what I have so far:
Sorry for asking such a basic question, but if anybody can help me with this code, I'll appreciate it.Code:#include <stdio.h>
#define KEY 0
int a;
int main() {
char c;
int key;
key = 0;
printf("You stand before a locked door. There is a key nearby.\n\n");
printf("a. Take key.\nb. Open door.\n");
c=getch();
if(c == 'a') {
printf("\nYou take the key.\n");
}
key = 1;
if(c == 'b') && KEY = 0 {
printf("\nYou do not have the key.\n");
if(c == 'b') && KEY = 1 {
printf("\nThe door unlocks with ease.\n");
}
}