0

this is probably a dumb question but how would I remove the array so that there is no max size on it.

struct StudentType
{
    string studentName;
    int testScore;//Between 0 and 100
    char grade;
};

const int NUM_STUDENTS = 20;

int main()
{
StudentType student[NUM_STUDENTS];
}


this is what i have tried


    StudentType i;

StudentType *student;

student = new (nothrow) StudentType [i];

Edited by beastie805

2
Contributors
2
Replies
21
Views
3 Years
Discussion Span
Last Post by beastie805
1

Use a pointer and expand the array as needed. Better yet, use std::vector or std::list, both will auto expand for you. For example:

StudentList* Students; // pointer to an array

or

std::vector<StudentType> Students;

Edited by Ancient Dragon

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.