I am a beginner in c++ programming and I was assigned a project to prompt the user for the name of a file. When inputted the output will be a directory containing party affiliation and office locations of the members of the House of Representatives from a particular state. It also requires the use of functions. Right now my program is not outputting the data of the files. This is what I have so far:
int main()
{
int count;
string filename;
ifstream inFile;
cout << "Please enter the text file: " <<endl;
cin >> filename;
if (filename == "A3.txt")
{
separator (35, 2, '#' );
inFile.open("A3.txt");
if (!inFile)
{
cout << "Invalid file name \n\n";
return 1;
}
count = 0;
cout <<"House of Representatives from New Jersey: \n\n";
file_reader ( inFile, count);
inFile.close ();
}
if (filename == "B3.txt")
{
separator (15, 1, '*' );
inFile.clear ();
inFile.open("B3.txt");
if (!inFile)
{
cout << "Invalid file name \n\n";
return 1;
}
cout <<"House of Representatives from Virginia: \n\n";
string officebuilding,firstname,lastname;
int districtnumber,roomnumber;
char party;
inFile>>districtnumber>>firstname>>lastname>>party>>officebuilding>>roomnumber;
cout << left << setw(12) << "Dist.#" << left << setw(20) << "Name" << left << setw(15) << "Party" << left << setw(15) << "Office" << left << setw(12) << "Room#" << endl;
cout << left << setw(12) << "======" << left << setw(20) << "=====" << left << setw(15) << "======" << left << setw(15) << "========" << left << setw(12) << "========" << endl;
while (inFile)
{
cout << left << setw(12);
name_printer(firstname,lastname);
cout << left << setw(25) << party << left << setw(15) << officebuilding<< left << setw(7) << roomnumber ;