Hello,
i tried to do this program in structure but have a hard time with it. tried everything and keep getting strange errors and i don't know off. please help
here is the program:
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
const int max = 20;
void inputData(People *);
void openfile();
void Quit();
int menu();
struct People
{
char *fn[max];
char *ln[max];
char *id[max];
int ssn[max];
char citizen[max];
};
int main()
{
People main;
int selection;
do
{
selection = menu();
switch (selection)
{
case 1:
inputData(main);
break;
case 2:
openfile();
break;
case 3:
Quit();
break;
default:
cout << "Invalid choice!";
}
}while(selection != 4);
return 0;
}
void inputData(People *input)
{
for (int count = 0; count < numEmployee; count++)
{
ofstream marketingfile("data.txt", ios:

ut | ios::app);
cout << "Enter First Name:\n";
*input.fn[count] = new char[max];
cin >> *input.fn[count];
cout << "Enter Last Name: \n";
*input.ln[count] = new char[max];
cin >> *input.ln[count];
cout << "Enter ID: \n";
*input.id[count] = new char[max];
cin >> *input.id[count];
cout << "Enter SSN: \n";
cin >> *input.ssn[count];
cout << "Are You a Citizen Y/N? \n";
cin >> *input.citizen[count];
marketingfile << *input.fn[count] << "\t\t" << *input.ln[count] << "\t\t" << *input.id[count] << "\t" << *input.ssn[count] << "\t\t" << *input.citizen[count] << endl;
marketingfile.close();
}
}
void openfile()
{
char filecontent[51];
fstream OpenFile;
// open the file
OpenFile.open("data.txt", ios::in);
// check if the file exits
if(!OpenFile)
{
cout << "ERROR: file does not exist.\n";
exit(0);
}
OpenFile.getline(filecontent, 51, '\n');
while (!OpenFile.eof())
{
cout << filecontent << endl;
OpenFile.getline(filecontent, 51, '\n');
}
// close the file
OpenFile.close();
}
void Quit()
{
exit(0);
}
int menu()
{
int choice;
do
{
cout << endl;
cout << "Menu Option\n\n";
cout << "1: Enter Data\n";
cout << "2: Display Data\n";
cout << "3: Quit";
cin >> choice;
if ((choice >= 1) && (choice <= 3))
{
return choice;
}
else
{
return 0;
}
}while (choice != 4);
exit(0);
}