Hi
I'm getting this error:
for every line in the display() function. Please help me to correct. I'm learning arrays. Thank you for your help and time.Code:error: expected primary-expression before ']' token|
Code:// student_data_structure_readfunc.cpp // read students' data and find number of A-graded students #include <iostream> #include <cstdlib> #include <iomanip> #include <string> using namespace std; //////////////////////////////////////////// struct Student {int rollno, age; string sex, name; float marks;}; //////////////////////////////////////////// const int N = 5; int A_graded; Student readfunc(); void display(Student dummystud[]); int main() { Student student[N]; int i; for ( i=0; i<N; i++) { cout << "enter student #" << (i+1) << " details below\n\n"; student[i] = readfunc(); } cout << "entered details are given below\n\n"; for (i=0; i<N; i++) { cout << "details of student #" << (i+1) << ":\n"; display(student); } cout << "\n\n"; system("pause"); return 0; } //------------------------------------------------------------- Student readfunc() { Student dummystud; cout << "enter roll no.: "; cin >> dummystud.rollno; cout << "enter name: "; cin >> dummystud.name; cout << "enter age: "; cin >> dummystud.age; cout << "enter sex: "; cin >> dummystud.sex; cout << "enter marks: "; cin >> dummystud.marks; if ( dummystud.marks >= 80) { A_graded++; } return dummystud; } //----------------------------------------------------------------- void diplay (Student dummystud[]) { cout << "roll no.: " << dummystud[].rollno; cout << "name: " << dummystud[].name; cout << "age: " << dummystud[].age; cout << "marks: " << dummystud[].marks; cout << "sex: " << dummystud[].sex; } //-----------------------------------------------------------------



LinkBack URL
About LinkBacks




