hello every one.. i m a newbie and was going through structures.the code is as followes:
#include<string>
using namespace std;
#define n_emp 3
struct workerdb {
string name;
short age;
int salary;
}employee[n_emp];
void printdb (workerdb);
int main() {
int n;
for (n=0;n<n_emp;n++) {
cout<<"name: "<<endl;
getline(cin,employee[n].name);
cout<<endl;
cout<<"age: "<<endl;
cin>>employee[n].age;
cout<<endl;
cout<<"salary: "<<endl;
cin>>employee[n].salary;
cout<<endl;
}
for (n=0;n<n_emp;n++) {
printdb (employee[n]);
}
return 0;
}
void printdb(workerdb employee) {
cout<<"name: "<<employee.name<<"\t";
cout<<"age: "<<employee.age<<"\t";
cout<<"salary: "<<employee.salary<<endl;
}
the problem is when i run the program.. for the first structure it asks for the name.. from the next it skips of name input but asks for other field.Thus when the database is complete i gate just the first name but rest structures it remains empty... please run it if i am not clear...
regards
cd-4+