On first iteration when you press Enter key then a newline character \n
is passed to the input along with y
. On second iteration scanf_s
reads \n
.
Change
scanf_s("%c", &c);
to
scanf_s(" %c", &c);
^Notice the space before %c
A space before %c
specifier can consume any number of white-space characters.