I am trying to modify code from MercuryAPI SDK for RFID reader. The program suppose to work by taking some argument from the use and print some message depend on the user's input. However, the program does not allow me to declare new variable inside the main function.
int main(int argc, char *argv[])
So, I tried to declare the variable as a global outside main function.
char c[1];
int main(int argc, char *argv[])
{
//Code that already written from MercuryAPI SDK
printf("\nEnter input: ");
scanf("%c",c[0]);
printf("\n%c", c[0]);
if(*c == 'O'){
printf("\nThe system is open");
}
else if(*c == 'X'){
printf("\nThe system is unopen");
}
}
The declaration is succeed, but the program terminate write after I input an argument. Are there any solution for this?