Program not working as expected
Code:
#include <stdio.h>
#include <string.h>
int main(){
char changeschedule;
char moviename[50];
int showtime;
int screennumber;
char addanothermovie;
char mname[50];
printf("Do you want to change the movie schedule? (Y for Yes, N for No)");
scanf("%c", &changeschedule);
if (changeschedule == 'Y'){
do{
printf("Enter the name of the movie:");
fgets(moviename, 50, stdin);
printf("Enter the showtime of the movie:");
scanf("%d", &showtime);
printf("Enter the screen number of the movie:");
scanf("%d", &screennumber);
printf("Do you want to add another movie to movie schedule? (Y for Yes, N for No)");
scanf("%c", &addanothermovie);
}while (addanothermovie == 'Y');
}
printf("Enter the name of the movie you want to buy ticket(s) for:");
fgets(mname, 50, stdin);
return 0;
}
The program is outputting:
Do you want to change the movie schedule (Y for Yes, N for No) Y
Enter the name of the movie:Enter the showtime of the movie:1230
Enter the screen number of the movie:3
Do you want to add another movie to movie schedule (Y for Yes, N for No)Enter t
he name of the movie you want to buy ticket(s) for:The Social Network
Why is the program not letting me enter the name of the movie?
And why is the program not letting me say Yes or No to specify whether I want to add another movie to movie schedule?
Thanks for your help.