while entering a name e.g: Alpha Beta, i cannot seem to get scanf to read the word after the blank space("Beta")...
#include<stdio.h>
struct student
{
int rollno, class;
char name[50], div[10];
};
int main()
{
struct student s1, *ptr;
ptr = &s1;
printf("\nEnter Student Class: ");
scanf("%d",&ptr->class);
printf("\nEnter Student Division: ");
scanf("%s",&ptr->div);
printf("\nEnter Student Rollno: ");
scanf("%d",&ptr->rollno);
printf("\nEnter Student Name: ");
scanf("%49s",&ptr->name);
printf("\nClass: %d\n", ptr->class);
printf("\nDivision: %s\n", ptr->div);
printf("\nRollno: %d\n", ptr->rollno);
printf("\nName: %s\n", ptr->name);
return 0;
}
when printing name, it returns only 'Alpha', not 'Alpha Beta' what should i do to get it to read both Alpha and Beta?