Hello guys, I'm trying to collect user input which combines integers with letters, but whenever it reaches the scanf for char it skips it and goes to next integer, could anybody explain why??? is it because main returns an integer,? I tried setting void main(void), and it sais that main has to be an integer during compilation.. here comes the code:
Could anybody explain why when it goes to scanf it doesnt let user to enter the letter for char and skipps it?
thank you!
#include<stdio.h>
void GetTime(void);
void GetLetter(void);
void ShowTime(void);
int MinuteAdd(int *p_hour, int *p_minute, char *p_mode);
// here comes the block of main
main()
{
int time=0;
int hour=0;
int minute=0;
char mode;
GetTime();
GetLetter();
ShowTime();
}
//here comes the function to get users input
void GetTime(void)
{
int hour=0;
int minute=0;
printf("Enter the hour:");
scanf("%d", &hour);
printf("\nEnter the minute:");
scanf("%d", &minute);
}
// here is the function to get a character since main returns an integer
void GetLetter(void)
{
char mode;
printf("\nEnter A (for AM) or P (for PM):");
scanf("%c", &mode);
}
//here comes the functio for getting amount of repetition times
void ShowTime(void)
{
int amount=0;
printf("\nEnter how many minutes to display:");
scanf("%d", &amount);
}