So i'm trying to create an array of only the 'active' people stored in a file, using the fstream library. I've browsed and found lots of people identifying what the problem is, but no solution has helped me solve my problem.
My compiler is telling me that a "Constant Expression is Required." All I'm trying to do is use a loop to identify the amount of people that are active, then create an array using this number. Can I really not do this in C++?
MyFile.clear();
MyFile.seekg( 0, ios :: beg );
Person temp;
int j = 0;
MyFile.read(( char* ) &temp, sizeof( Person ));
while ( ! MyFile.eof() )
{
if ( temp.personActive )
j++;
MyFile.read(( char* ) &temp, sizeof( Person ));
}
Person testArray[ j ];