CODE:
#include<iostream>
using namespace std;
struct Emp{
int empno;
char name[100];
char designation[100];
float basic;
} employee;
int main(){
cout<<"ID: ";
cin>>employee.empno;
cout<<"Name: ";
gets(employee.name);
cout<<"Designation: ";
gets(employee.designation);
cout<<endl;
cout<<"Details: "<<endl;
cout<<employee.empno<<endl;
cout<<employee.name<<endl;
cout<<employee.designation<<endl;
return 0;
}
OUTPUT: https://i.stack.imgur.com/Hkj8i.png
When I run the code, the cursor skips 'gets(employee.name)' and goes to 'gets(employee.designation)'. Can anyone clarify the reason for this behavior and suggest a method to correct it?