How to insert lines of data from a file to a character array and place it into another file.

I am working on an assignment that requires the use of the char array. I haven't used a character array yet so I am a little confused on how too properly store information and output it. This is what I have so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
  class Student
{
    public:
    Student(char, char, int, double);
    
    void setFirstName(char);
    void setLastName(char);
    void setStudentID(int);
    void setGPA(double);
    
    char getFirstName();
    char getLastName();
    int getStudentID();
    double getGPA();
    
    void getStudentRecord();
    
    private:
    char firstName[16];
    char lastName[16];
    int studentID;
    double gpa;
};





Student::Student(char firstName, char lastName, int studentID, double gpa)
{
    setFirstName(firstName);
    setLastName(lastName);
    setStudentID(studentID);
    setGPA(gpa);
}



void Student::setFirstName(char f)
{
    firstName[15] = f;
}

void Student::setLastName(char l)
{
    lastName[15] = l;
}

void Student::setStudentID(int num)
{
    studentID = num;
}

void Student::setGPA(double grade)
{
    gpa = grade;
}



char Student::getFirstName()
{
    return firstName[15];
}

char Student::getLastName()
{
    return lastName[15];
}

int Student::getStudentID()
{
    return studentID;
}

double Student::getGPA()
{
    return gpa;
}



void Student::getStudentRecord()
{
    cout << setw(20) << firstName << setw(20) << lastName << setw(12) << studentID << setw(10) << gpa << endl;
}




int main()
{
    //Storage
    char fName[16];
    char lName[16];
    int id;
    double score;
    vector <Student> records;
    string inspect;
    
    //Input and Output streams
    ifstream first;
    ifstream last;
    ofstream book;
    first.open("firstnames.txt");
    last.open("lastnames.txt");
    book.open("records.txt");
    
    
    //c++11 random number engine
    default_random_engine engine;
    uniform_int_distribution<> distributionInt(1000, 4000);
    uniform_real_distribution<> distributionReal(1.0, 4.0);
    
    //fill vector of class objects
    while(first.eof() == false)
    {
        getline(first, inspect);
        for(int i = 0; i < inspect.size(); i++)
        {
           fName[i] = inspect[i];
        }
        
        getline(last, inspect);
        for(int i = 0; i < inspect.size(); i++)
        {
           lName[i] = inspect[i];
        }
        
        id = distributionInt(engine);
        score = distributionReal(engine);
        
        records.push_back(Student(fName[15], lName[15], id, score));
    }
    
    //close input files
    first.close();
    last.close();
    
    //place vector content in output file
    for(int i = 0; i < records.size(); i++)
    {
        cout << records.at(i).getFirstName() << endl;
    }
    
    //display output file content
    
    book.close();
    
    return 0;
}


I am storing the information in a character array and then place it in a vector of class objects. However after testing to see if the character arrays were storing information properly, it would print out nothing but blanks on every line. How do I make it so that it properly displays the information from the character array?
Topic archived. No new replies allowed.