#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
int main()
{
struct student
{
int roll;
char grade;
};
struct student s1,*p;
p=&s1;
printf("Enter the roll no.: ");
scanf("%d", &s1.roll);
printf("Enter the grade: ");
scanf("%c", &s1.grade);
printf("Roll no. %d\nGrade %c", (*p).roll,p->grade);
return 0;
}
apparently I can solve this by adding a space in the second scanf() but if I make another program that just takes two characters(or valies in strings) one after another and then print them, it works fine even without accounting for the buffer input. Why is that?