I have used the following code snippet to read several values but the single character constant variable rating is not accepting any value. It doesn't execute that particular scanf
statement. How to resolve this?
char name[100],locality[100],vision[100],mission[100];
char rating;
int dept,stud;
printf("Enter college name\n");
scanf("%s",name);
printf("Enter college locality\n");
scanf("%s",locality);
printf("Enter college's vision\n");
scanf("%s",vision);
printf(" Enter college's mission\n");
scanf("%s",mission);
printf("Enter the number of departments\n");
scanf("%d",&dept);
printf(" Enter student strength\n");
scanf("%d",&stud);
printf(" Enter college rating\n");
scanf("%c",&rating); //not reading this value
printf("%s\n%s\n",name,locality);
There is no compile error or run time error in this above code.
when I use the following code the variable is accepting value.
char rating;
printf(" Enter college rating\n");
scanf("%c",&rating);