This is for an assignment so I'm following assignment guidelines of the desired struct layout as well as the overloads. Trying to get my program to read each line and assign each line to the variable.

The text file looks like:

```
John 

S

Maggey

G

```

and my code looks like:

```
#include "iostream"
#include "fstream"
namespace
{
    char buffer[1024];
    int allocated = 0;
}

//====================================================================
struct student
{
    char *firstname;
    char lastname;
    int studentId;
    int occupied;

    student() : lastname(0), studentId(0), occupied(0)
    {
        firstname = new char[64];
        for (int i = 0; i < 64; ++i)
            firstname[i] = 0;
    }

    student(int s)
    {
        std::cout << "constructor" << std::endl;
        std::cout << "Allocated: " << allocated << std::endl;
        int currentLoc = allocated;
        allocated += s;
        firstname = new (&buffer[currentLoc]) char[s];
        for (int i = 0; i < 64; ++i)
            firstname[i] = 0;
    }

    void *operator new(size_t s)
    {
        std::cout << "Operator new allocated: " << allocated << std::endl;
        int currentLoc = allocated;
        allocated += s;
        return &buffer[currentLoc];
    }

    void student::operator delete(void *ptr)
    {
        std::cout << "Delete called " << std::endl;
        std::free(ptr);
    }

    student::~student()
    {
    }
};

//====================================================================
int main(int argc, char** argv)
{
    student *studentLoader = new student[25];

    std::fstream fin;
    fin.open("students.txt");
    char ln;
    for (int i = 0; i < 25; ++i)
    {
        fin.getline(studentLoader[i].firstname, 99);
        fin.getline(ln, 64);
        studentLoader[i].lastname = ln;
        studentLoader[i].studentId = (rand() % (9999 - 999)) + 999;
        studentLoader[i].occupied = 1;
        if ((i % 10) == 0)
        {
            std::cout << "First name: " << studentLoader[i].firstname << " Last initial: " << studentLoader[i].lastname << " ID: " << studentLoader[i].studentId << std::endl;
            delete[] studentLoader;
        }
    }
    fin.close();

    return 0;
}

```

I also tried doing :

```
    std::fstream fin;
    fin.open("students.txt");
    char ln;
    for (int i = 0; i < 25; ++i)
    {
        fin.getline(studentLoader[i].firstname, 99);
        fin.getline(studentLoader[i].lastname, 99);
        studentLoader[i].lastname = ln;
        studentLoader[i].studentId = (rand() % (9999 - 999)) + 999;
        studentLoader[i].occupied = 1;
        if ((i % 10) == 0)
        {
            std::cout << "First name: " << studentLoader[i].firstname << " Last initial: " << studentLoader[i].lastname << " ID: " << studentLoader[i].studentId << std::endl;
            delete[] studentLoader;
        }
    }
    fin.close();

    return 0;
}

```

But would receive an error for the second attempt to getline. 

When trying 

```
fin >> studentLoader[i].firstname;

```

nothing would be inserted into the variables.