Newbie question - struct & arrays
I am working on a homework assignment (a simple name and grade sorting program) but I am obviously missing something and am not seeing it.
Code:
#include <iostream>
#include <stdlib.h>
#include <string.h>
#define MAX 25
#define MAXN 10
using namespace std;
int nst;
struct NGrade {
char name[MAX];
int grade;
};
int main(){
cout << "How many students do you want to process?" << endl;
cin >> nst;
struct Ngrade grades[MAXN];
int i;
for(i=0; i < nst; i++)
{
cout << "Enter name for student #" << nst << endl;
//cin >> grades[nst].name;
cout << "Enter grade for student #" << nst << endl;
//cin >> grades[nst].grade;
}
cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
The error I get is:
Code:
22 D:\Dev-Cpp\grade2\main.cpp elements of array `Ngrade grades[10]' have incomplete type
22 D:\Dev-Cpp\grade2\main.cpp storage size of `grades' isn't known
Ideally I had wanted to set it up so that the array quantity (number of names and grades) in the structure was determined by the user at runtime but I can't seem to get it to take a predetermined number of items.
Simply put I don't understand why it doesn't like my array declaration.
Thanks in advance from the frustrated and confused,
n3m0