Here is my code . Switch statement doesn't working in this. why?
int callprocess(FILE *File)
{
int Rec = 0; // record number
char tcode[3];
//char buffer[30];
struct timeval b,e;
long int tms,tme;
do
{
printf("\nMenu :Init, Dummy, Add or Quit ( I, U, A or Q) : ");
switch(toupper(getchar()))
{
case 'I' :
printf("Creating dummy file of 10 entries\n");
InitFile(File);
break;
case 'U' :
printf("Creating dummy file of 1000 entries\n");
adddummyfile(File);
break;
case 'A' :
Rec = AddRecord(File);
printf("Record #%d Added\n\n", Rec);
break;
case 'Q' :
fclose(File);
//if(c=='1')
// deletefile(FNAME);
//else
//deletefile(TEMPF);
return 0;
}while(getchar() != '\n');
}while (1);
}
int main (void)
{
FILE *File;
char c;
srand(time(NULL));
printf("Random Access File Demonstration\n\n");
printf("Which File Do You want to read ? 1. abc.cli 2. tmp.cli ( 1 , 2) : ");
scanf("%c",&c);
if(c=='1')
File = FileOpen(FNAME);
else if (c == '2')
File = FileOpen(TEMPF);
if (!File)
{
printf("Curses foiled again!\n\n");
exit(-1);
}
callprocess(File);
return 0;
}