I am trying to read lines from a file into an array using the fstream and then printing them out. I tried doing this by using a for loop and a getline command, but the program keeps crashing and giving me the "Exception Thrown: write access violation" message. Is there something I should fix in my program or is there a better way to do this?
File Text:
Fred Smith 21
Tuyet Nguyen 18
Joseph  Anderson 23
Annie Nelson 19
Julie Wong 17
Code:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
    cout << "Harrison Dong - 7/21/17" << endl;
    string fileStuffs[4];
    ifstream fin;
    fin.open("C:\\Users\\Administrator\\Documents\\Summer 2017 CIS 118-Intro 
to Comp. Sci\\Module 17\\firstLastAge.txt");
    if (!fin.is_open()) {
        cout << "Failure" << endl;
    }
    for (int i = 0; i < 5 && !fin.eof(); i++) {
        getline(fin, fileStuffs[i]);
        cout << fileStuffs[i] << endl;
    }
    fin.close();
    system("Pause");
    return 0;
}
Thanks!
 
    