Im trying to write a program that checks the weather and it uses Characters to check so it runs, does the first user input then skips the second users input. So basically I just wanna know how with this code I can make if statements not skip users inputs
#include <stdio.h>
#include <string.h>
void tennis( void ) {
char Outlook[1];
printf("What is the outlook?\n S - sunny\n O - overcast\n R - rainy\n");
scanf("%c", Outlook);
if(!strcmp(Outlook, "S") == 0)
{
printf("What is the humidity like?\n H - high\n N - normal\n");
if (!strcmp(Outlook, "H") == 0)
{
printf("It is just too hot and sticky for tennis.");
scanf("%c", Outlook);
}
else if (strcmp(Outlook, "N") == 0)
{
printf("This is a good day for tennis.");
}
else
{
printf("Invalid choice for humidity:\n 'X' Valid options are 'H', and 'N'.");
}
}
}
Aucun commentaire:
Enregistrer un commentaire