I have finished editing the program but I still have a couple of errors that I can't figure out, please help
Errors:
Error 1 error C2601: 'split' : local function definitions are illegal \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\err\err\err.cpp 97
Error 2 fatal error C1075: end of file found before the left brace '{' at '.\err.cpp(82)' was matched \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\err\err\err.cpp 137
/* Specification:
Gilberto Sotomayor-Candelaria
Lab 7 Exercise 3
Append and display records in a address database*/
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void menu(void);
void writeData(void);
void readData(void);
string * split(string, char);
const char FileName[] = "c:/TestAddress.txt";
int main ()
{
menu();
return 0;
} //end main
void menu(void)
{
char choice = ' ';
cout << "\nWhat Would You Like To Do With These Records: \n\n";
cout << "Append Records (A), Show Records (S), or Exit (E)\n";
cin >> choice;
while(choice == 'A' || choice == 'S');
{
switch(choice)
{
case 'a':
case 'A':
writeData();
break;
case 's':
case 'S':
readData();
break;
}
cout << "What Else Would You Like To Do?\n";
cout << "Append Records (A), Show Records (S), or Exit (E)\n";
cin >> choice;
}
}//end menu
void writeData(void)
{
char choice = 'Y';
string name = "";
string street = "";
string city = "";
string state = "";
string zipCode = "";
ofstream outMyStream(FileName, ios::app);
do
{
cout << "\nEnter The Name: ";
getline(cin, name);
cout << "\nEnter The Street: ";
getline(cin, street);
cout << "\nEnter The City: ";
getline(cin, city);
cout << "\nEnter The State: ";
getline(cin, state);
cout << "\nEnter The Code: ";
cin >> zipCode;
outMyStream << name << "," << street << "," << city << "," << state << "," << zipCode;
cout << "\nEnter another Record? (Y/N) ";
cin >> choice;
}
while (choice == 'Y' || choice == 'Y' );
outMyStream.close();
}//end write data
void readData(void)
{
ifstream inMyStream (FileName);
string lineBuffer;
while (!inMyStream.eof() )
{
getline (inMyStream, lineBuffer, '\n');
string *theFields = split(lineBuffer, ',');
cout << "Name...... " << theFields[0] << endl;
cout << "Street.... " << theFields[1] << endl;
cout << "City...... " << theFields[2] << endl;
cout << "State..... " << theFields[3] << endl;
cout << "Zip code.. " << theFields[4] << endl;
}//end read data
string * split(string theLine, char theDeliminator)
{
//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] == theDeliminator)
{
splitCount++;
}
}
splitCount++; //add one more to the count because there is not an ending comma
//create an array to hold the fields
string* theFieldArray;
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] != theDeliminator)
{
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