An array is a block of contiguous memory - meaning your most likely going to have more than one element in that array. Secondly, the name of an array is the address of the first element in that array.
Originally Posted by jackson6612
In your case you have N elements. In the following code you give the address of the first element in your array.
cout << "details of student #" << (i+1) << ":\n";
In your definition here you tell the compiler to expect an array again.
void display(Student dummystud)
However in the ensuing cout statements you don't tell the compiler to actually go over all the elements in that array.
cout << "roll no.: " << dummystud.rollno;
cout << "name: " << dummystud.name;
cout << "age: " << dummystud.age;
cout << "marks: " << dummystud.marks;
cout << "sex: " << dummystud.sex;
an array is a block of contiguous memory. your compiler knows this and is expecting you to tell it which element to display. So how would you make it display all the elements in your array?
that is what this error
is telling you. It's not going to magically go over each element for you. You have to tell it to.
error: expected primary-expression before ']' token
something needs to be between those brackets