I'm working on an address database. The assignment is to append and display records in said database. The records are to be written to file in CSV format and then read from the file using a split function to separate the file string into separate fields (name, address, city, and so on). The professor provided a basic code with comments to start this particular assignment and I think I've got a near workable solution, but I'm running into a couple of issues.

1) The writeData function isn't looping. Regardless of the answer provided (Y or N), it simply exits the program.

2) I'm not really sure that I understand the split function. I understand what it is supposed to do and the code that the professor has provided compiles as is, so I'm not really sure what I need to be changing around. The file output that he is looking for should look similar to this:

Show Records
__________________________________________
Record #1
Name...........John Smith
Street..........902 Union Ave
City.............Any Town
State...........TX
Zip Code......78552
__________________________________________
Record #2
Name...........Eric Jones
Street..........345 State Way
City.............Fresno
State...........CA
Zip Code.......93432

I haven't really changed much of this function (mainly just included the comma ',' as the delimiter) and the comments written in the function are the professor's. I'm not sure if I'm just trying to make this more complex than it needs to be or what. And since the writeData isn't working, then I'm not sure if the split function will work either.

Anyone have any thoughts?
Thanks.

Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

void menu(void);
void writeData(void);
void readData(void);
string * split(string theLine, char);

const char FileName[] = "TestAddress.txt";
int main () 
{
    menu();
    return 0;
} //end main

void menu(void) //allow user to choose to append records, display records or exit the program
{
    cout << "Do you wish to (A)ppend records, (D)isplay records, or (E)xit" << endl;
    char answer;
    cin >> answer;
    
    switch (answer)
    {    
    case 'A':; case 'a':;
            writeData(); 
            break;
    case'D': case 'd':;
            readData();
            break;
    case'E': case 'e':;
            cout << "Thank you for using our program." << endl;
            break;
        default:
            cout << "Invaild selection" << endl;
    }
}


void writeData(void)//Write the Address Info to a file
{
    bool another = true;
    fstream addInfo;
        addInfo.open("TestAddress.txt", ios::out|ios::app);

    do
    {
        cout << endl;
        cout << "First and Last Name : " << endl;
        string name;
        getline(cin, name, '\n');
        cin >> name;

        cout << endl;
        cout << "Street Address: " << endl;
        string address;
        getline(cin, address, '\n');
        cin >> address;

        cout << endl;
        cout << "City: " << endl;
        string city;
        getline(cin, city, '\n');
        cin >> city;

        cout << endl;
        cout << "State: " << endl;
        string state;
        getline(cin, state, '\n');
        cin >> state;

        cout << endl;
        cout << "Zip Code: " << endl;
        string zip;
        getline(cin, zip, '\n');
        cin >> zip;

        addInfo << name << "," << address << "," << city << "," << state << "," << zip << endl;

        cout << endl;
        cout << "Enter Another Record? (Y/N)" << endl;
        int answer;
        cin >> answer;
            if ((answer = 'N') || (answer = 'n'))
                another = false;
            else
                another = true;
    }
    while (another);
    

addInfo.close();
}

void readData(void)
{
    string name, address, city, state, zip;
    fstream addInfo;
    addInfo.open("TestAddress.txt", ios::in);
        while(!addInfo.eof())
        {
            addInfo >> name >> address >> city >> state >> zip;
            string*split(string theLine, char); //use split function to break up to string into separate
        }
    addInfo.close();
}

string * split(string theLine, char)
{
        //Break theline into fields and save the fields to an array.
        //Each field will occupy one element in a character array.
        //theLine is a string with fields separated with theDeliminator character.
        //Assumes the last field in the string is terminated with a newline.
        //Useage: string *theFields = split(lineBuffer, ',');

        //determine how many splits there will be so we can size our array
        int splitCount = 0;
        for(int i = 0; i < theLine.size(); i++)
        {
            if (theLine[i] == ',')
            splitCount++;
        }
        splitCount++; //add one more to the count because there is not an ending comma 

        
        string* theFieldArray;//create an array to hold the fields
        theFieldArray = new string[splitCount]; //split the string into seperate fields
        string theField = "";
        int commaCount = 0;

        for(int i = 0; i < theLine.size(); i++) //read each character and look for the deliminator
        { 
            if (theLine[i] != ',') 
            {
                theField += theLine[i]; //build the field
            }
            else 
                { //the deliminator was hit so save to the field to the array
                    theFieldArray[commaCount] = theField; //save the field to the array
                    theField = "";
                    commaCount++;
                }
        }
        theFieldArray[commaCount] = theField; //the last field is not marked with a comma...

        return theFieldArray;
} //end split