In K.N. King's book C Programming: A modern approach, chapter 7 there is an exercise 9 (and also exercise 8), which asks the user to enter a 12-hour time and then converts it into a 24-hour one.
e.g. 9:11 PM -> 21:11
To my question, I understand how to get the times in the format of e.g. 8:37PM or 8:37[space]PM but I have no idea how to make it work for both formats.
Thanks
int h, m;
char meridiem;
printf("Enter a 12-hour time: ");
scanf_s("%d:%d%c", &h, &m, &meridiem);
printf("%c\n", meridiem);
NOTE: I do realise that I am getting only one character.