0
Display the input data!!!! by using function
include<iostream> using namespace std; struct student{ string name; string address; }; void inputdata(student& s1) { cin>>s1.name; cin>>s1.address; } void display () { // } int main() { int no_of_students; cout<<"enter no. of student\n"; cin>>no_of_students; student* s= new student[no_of_students]; for(int i=0;i<no_of_students;i++) { cout<<"student#"<<i+1<<"\n"; inputdata(s[i]); } }
1 Answer
0
Try to add this code :
void display(student& s2)
{
cout << s2.name << endl;
cout << s2.address << endl;
}
//and this part in main after your "for"
for (int i = 0; i<no_of_students; i++)
{
cout << "student#" << i + 1 << "\n";
//inputdata(s[i]);
display(s[i]);
}
Good luck!