I try to learn C programming but I have a question about it.
Can you explain why do some programs close after entering number or characters suddenly altough I use conio.h and getch();. For example, I wrote some codes to develop my programming skills. after compiling with Dev C++, my program start but after writing a number between 0-8 it close suddenly.Why? Have I made any mistakes while I was writing codes? but I faced some problems like this when I compiled other codes. What is the general problems?
Code:
#include<stdio.h>
#include<conio.h>
main()
{
int sayi;
printf("Please write a number:\n");
scanf("%d",&sayi);
switch(sayi){
case 1: printf("Monday\n");
break;
case 2: printf("Tuesday\n");
break;
case 3: printf("Wednesday\n");
break;
case 4: printf("Thursday\n");
break;
case 5: printf("Friday\n");
break;
case 6: printf("Saturday\n");
break;
case 7: printf("Sunday\n");
break;
default: printf("No day\n");
getch();
}
}