These are the instructions and the point at which I'm up to.
Specify a structure called Date with day, month and year as its three int members.So essentially we don't know the size of the array and the user doesn't specify size, it's all done on the fly.
Specify a structure called Student with the following data:
name: string which could include spaces for last_name, first_name
id: int
units: int
gpa: float
date: Date
Keep reading Student structures from keyboard until a NULL string is entered for student name. As each Student is entered, dynamically allocate memory for it and store its pointer returned by new in an array of Student pointers.
Point I'm up to:
#include<iostream>What I can't figure out is where or how to stick the dynamically allocated memory continually back into an array of student pointers.
#include<string>
using namespace std;
struct Date
{
int month, day, year;
};
struct Student
{
string first_name, last_name;
int id, units;
float gpa;
Date date;
};
int main()
{
Student *std;
string test_string;
int count = 0;
char slash;
std = new Student;
cout << endl << "First Name: ";
getline(cin, test_string);
while(test_string != "")
{
std->first_name = test_string;
cout << "Last Name: ";
getline(cin, std->last_name);
cout << "Student ID: ";
cin >> std->id;
cout << "GPA: ";
cin >> std->gpa;
cout << "Enrolled [mm/dd/yyyy]: ";
cin >> std->date.month >> slash >> std->date.day >> slash >> std->date.year;
cin.ignore();
cout << endl << "First Name: ";
getline(cin, test_string);
if(test_string != "")
{
count++;
std = new Student;
}
}
return 0;
}