struct stu_dat //outside main function
{
int rollno;
char name[45],
float average;
}s1;
char ans='y'; //inside main function
while(ans=='y')
{
cin>>s1.rollno;
cin.get(s1.name,45);
cin>>s1.average;
cout<<"want to enter more data?';
cin>>ans;
}
No compilation problem.when executing prompt waits for inputting rollno
but, as soon as i enter a char string it keeps looping displaying the "want to enter more data?".i cant understand what is going on,as there is no compilation problem and runs good till i input the name.