I'm getting this error:
error: expected primary-expression before ']' token|
for every line in the display() function. Please help me to correct. I'm learning arrays. Thank you for your help and time.
// 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[COLOR="orange"][SIZE="3"][i][/SIZE][/COLOR]);
}
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;
}
//-----------------------------------------------------------------
[B][COLOR="red"]void diplay (Student dummystud[])[/COLOR][/B]
{
cout << "roll no.: " << dummystud[].rollno;
cout << "name: " << dummystud[].name;
cout << "age: " << dummystud[].age;
cout << "marks: " << dummystud[].marks;
cout << "sex: " << dummystud[].sex;
}
//-----------------------------------------------------------------
Edited by jackson6612, 04 June 2011 - 03:47 PM.


Sign In
Create Account


Back to top









