hi, i'm making a database system for my module project. my database system is about a gaming store where records can be stored if there is any games rental
i have a problem in validating the games console input section. logically, i want it to validate inputs such as PS3, XBOX 360 etc. only. And only those inputs and its lowercase counterparts are acceptable. however, my code didn't seem to work. even if i inputted the correct item, it still displays the warning.
for (int i = 0; i < 4; ++i)
record.console[i] = toupper(record.console[i]); // converts character by character to upper
if (strcmp(record.console, "PS3") || strcmp(record.console, "X360") ...
void getconsole(void) {
int valid;
int i;
do {
fflush(stdin);
gotoxy(13,6);
clreol();
gets(record.console); // this isn't safe for input over 4 chars (plus the null)
for (i=0; i<4; i++) // the for loop is just used to convert the array
record.console[i] = toupper(record.console[i]);
if (strcmp(record.console, "PS3") || strcmp(record.console, "X360") || strcmp(record.console, "WII") || strcmp(record.console, "PSP") || strcmp(record.console, "NDS"))
valid=1;
else {
gotoxy(26,21);
textcolor(RED);
cprintf("Accepted consoles are PS3/X360/WII/PSP/NDS only!");
textcolor(RED);
getch();
gotoxy(12,6);
clreol();
valid=0;
}
} while(!valid);
}