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]); } }

22nd Oct 2017, 2:45 PM
Abrar Hussain
Abrar Hussain - avatar
1 Respuesta
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!
23rd Oct 2017, 5:02 AM
derXred
derXred - avatar