Why is getchar ( ) not working?

Since i want to type in with Enter, i initially wrote down my code with getchar ( ), however it didn't work and i was forced to replace it with getche ( ). Is there a way to use getchar ( ) instead of getche ( )?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <conio.h>
int main(void)
{
	char ch;
	int d, m, y;
	int i, num;
	num = 0;
	for (i = 1; i > num; )
	{
		printf("Enter day: ");
		scanf_s("%d", &d);
		printf("Enter month: ");
		scanf_s("%d", &m);
		printf("Enter year: ");
		scanf_s("%d", &y);
		if (y % 4 == 0 && m == 2)
		{
		if (d == 29)
			printf("The next day is: 01.03.%d\n", y);
		else if (d < 30)
			printf("The next day is: %d.%d.%d\n", d + 1, m, y);
		}
			else if (d == 31 && m == 1)
				printf("The next day is: 01.02.%d\n", y);
			else if (d == 28 && m == 2)
				printf("The next day is: 01.03.%d\n", y);
			else if (d == 31 && m == 3)
				printf("The next day is: 01.04.%d\n", y);
			else if (d == 30 && m == 4)
				printf("The next day is: 01.05.%d\n", y);
			else if (d == 31 && m == 5)
				printf("The next day is: 01.06.%d\n", y);
			else if (d == 30 && m == 6)
				printf("The next day is: 01.07.%d\n", y);
			else if (d == 31 && m == 7)
				printf("The next day is: 01.08.%d\n", y);
			else if (d == 31 && m == 8)
				printf("The next day is: 01.09.%d\n", y);
			else if (d == 30 && m == 9)
				printf("The next day is: 01.10.%d\n", y);
			else if (d == 31 && m == 10)
				printf("The next day is: 01.11.%d\n", y);
			else if (d == 30 && m == 11)
				printf("The next day is: 01.12.%d\n", y);
			else if (d == 31 && m == 12)
				printf("The next day is: 01.01.%d\n", y + 1);
			else if (m == 1 && d < 32 || m == 2 && d < 29 || m == 3 && d < 32 || m == 4 && d < 31 || m == 5 && d < 32 || m == 6 && d < 31 || m == 7 && d < 32 || m == 8 && d < 32 || m == 9 && d < 31 || m == 10 && d < 32 || m == 11 && d < 31 || m == 12 && d < 32)
				printf("The next day is: %d.%d.%d\n", d + 1, m, y);
			else printf("There are not such days in this month");
			printf("\n");
			printf("Do you wish to continue?");
			printf(" (Y/N)\n");
			printf("Answer: ");
			ch = _getche();
			printf("\n");
			if (ch == 'Y')
			{
				printf("\n");
				i++;
				num++;
			}
			else if (ch == 'N')
			{
				printf("\n");
				i--;
			}
			else
			{
				printf("Invalid command!");
				printf("\n");
				printf("Retype your decision: ");
				if (ch != 'Y' && ch != 'N')
				{
					for (ch = _getche(); ch != 'Y' && ch != 'N'; ch = _getche());
					printf("\n\n");
					i++;
					num++;
					if (ch == 'N')
						i--;
				}
			}
	}
	return 0;
}
Topic archived. No new replies allowed.