Hi guys, fairly new to C.
Basically, i'm just creating a simple data entry form and i was wondering if there was another way apart from using strcmp to validate text input.
for example, i already have this:
Code:
do
{
printf("Enter your favourite sport from these options (Football, Basketball, Hockey or Baseball): ");
scanf("%s", sport);
for (i = 0 ; i < (int)strlen(sport); i++)
{
if (i == 0) cpu[i] = toupper(sport[i]);
else sport[i] = tolower(sport[i]);
}
}
while (strncmp(sport, "Football", 8) != 0 && strncmp(sport, "Basketball", 10) != 0 && strncmp(sport, "Hockey", 6) != 0 && strncmp(sport, "Baseball", 8) != 0);
at the moment, it doesn't accept input other than those sports but is there another way to do this without using strncmp?
thanks guys!