Sorry, I know I'm very new at this, but I'm also very interested. Here's what I got so far:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct EmpInfo
{
string fname;
string mname;
string lname;
string SSN;
string hours;
string rate;
string CurrentEvalNum;
string dept;
string exempt;
};
int main()
{
genesis:
string choice;
cout << "Type \'add\' to add an employee";
cout << ", type \'find\' to look-up an employee";
cout << ", or type \'exit\' to exit: ";
cin >> choice;
if ( choice == "a[0]"||"A[0]"
{
EmpInfo ei;
ofstream myFile("C:/Windows/Desktop/employees.txt", ios:ut | ios::app);
cout << "First Name: ";
cin >> ei.fname;
myFile << "ei.fname| " << ei.fname << endl;
cout << "Middle Name: ";
cin >> ei.mname;
myFile << "ei.mname| " << ei.mname << endl;
cout << "Last Name: ";
cin >> ei.lname;
myFile << "ei.lname| " << ei.lname << endl;
cout << "Social Security Number: ";
cin >> ei.SSN;
myFile << "ei.SSN| " << ei.SSN << endl;
cout << "Rate: ";
cin >> ei.rate;
myFile << "ei.rate| " << ei.rate << endl;
cout << "Current Evaluation (in number): ";
cin >> ei.CurrentEvalNum;
myFile << "ei.CurrentEvalNum| " << ei.CurrentEvalNum << endl;
cout << "Department: ";
cin >> ei.dept;
myFile << "ei.dept| " << ei.dept << endl;
cout << "Is " << ei.fname << " " << ei.lname << " exempt? \'y\' or \'n\': ";
cin >> ei.exempt;
myFile << "ei.exempt| " << ei.exempt << endl << endl;
myFile.close();
}
else if (choice == "f[0]" || "F[0]"
{
string searched;
cin >> searched;
if (searched == "fname" || "FNAME"
{
}
if (searched == "lname" || "LNAME"
{
}
if (searched == "SSN" || "ssn"
{
}
}
goto genesis;
else if (choice == "e[0]" || "E[0]"
{
break;
}
}
My question is that how would I instead of just ammending to the file to be able to edit it also via arrays. All the output in employees.txt are saved like "ei.fname| Chris" Thanks in advance!
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
struct EmpInfo
{
string fname;
string mname;
string lname;
string SSN;
string hours;
string rate;
string CurrentEvalNum;
string dept;
string exempt;
};
int main()
{
genesis:
string choice;
cout << "Type \'add\' to add an employee";
cout << ", type \'find\' to look-up an employee";
cout << ", or type \'exit\' to exit: ";
cin >> choice;
if ( choice == "a[0]"||"A[0]"
{
EmpInfo ei;
ofstream myFile("C:/Windows/Desktop/employees.txt", ios:ut | ios::app);
cout << "First Name: ";
cin >> ei.fname;
myFile << "ei.fname| " << ei.fname << endl;
cout << "Middle Name: ";
cin >> ei.mname;
myFile << "ei.mname| " << ei.mname << endl;
cout << "Last Name: ";
cin >> ei.lname;
myFile << "ei.lname| " << ei.lname << endl;
cout << "Social Security Number: ";
cin >> ei.SSN;
myFile << "ei.SSN| " << ei.SSN << endl;
cout << "Rate: ";
cin >> ei.rate;
myFile << "ei.rate| " << ei.rate << endl;
cout << "Current Evaluation (in number): ";
cin >> ei.CurrentEvalNum;
myFile << "ei.CurrentEvalNum| " << ei.CurrentEvalNum << endl;
cout << "Department: ";
cin >> ei.dept;
myFile << "ei.dept| " << ei.dept << endl;
cout << "Is " << ei.fname << " " << ei.lname << " exempt? \'y\' or \'n\': ";
cin >> ei.exempt;
myFile << "ei.exempt| " << ei.exempt << endl << endl;
myFile.close();
}
else if (choice == "f[0]" || "F[0]"
{
string searched;
cin >> searched;
if (searched == "fname" || "FNAME"
{
}
if (searched == "lname" || "LNAME"
{
}
if (searched == "SSN" || "ssn"
{
}
}
goto genesis;
else if (choice == "e[0]" || "E[0]"
{
break;
}
}
My question is that how would I instead of just ammending to the file to be able to edit it also via arrays. All the output in employees.txt are saved like "ei.fname| Chris" Thanks in advance!