Question
my c++ code keeps saying file read error, i need help correcting it. #include #include #include #include #include #include #include using namespace std; struct Person
my c++ code keeps saying file read error, i need help correcting it.
#include #include #include #include #include #include #include using namespace std; struct Person { string firstName; string lastName; int customer_id; }; struct Address { string street; string city; string state; int zip_code; }; struct Date { string month; int day; int year; }; struct Renewal { int months_left; string month_1; int day_1; int year_1; }; struct Customer { Person person; Address address; Date date; Renewal renewal; }; void OpenInputFile(ifstream&); void OpenOutFile(ofstream&); //void PrintHeadingOutput(ofstream&); void OutPutInfo(Customer&, ofstream&); bool InputInfo(Customer&, ifstream&); int main() { ifstream inFile; ofstream outFile; Customer info; OpenInputFile(inFile); OpenOutFile(outFile); // PrintHeadingOutput(outFile); while(InputInfo(info,inFile)) { OutPutInfo(info,outFile); } if (inFile.fail() && !inFile.eof()) { string infilename; cout An error has occured while reading "; cout the input file. Error in file content " Terminating program!!!"> infilename; cin.ignore(INT_MAX,' '); cout Input file failed to open properly!! "; cout Attempted to open file: " Please try again... "; cout > infilename; cin.ignore(INT_MAX,' '); cout > outfilename; cin.ignore(INT_MAX,' '); cout Output file failed to open properly!! "; cout Attempted to open file: " Please try again... "; cout > outfilename; cin.ignore(INT_MAX,' '); cout > info.person.customer_id; getline(inFile, info.address.street,' '); getline(inFile, info.address.city,' '); getline(inFile, info.address.state,' '); inFile >> info.address.zip_code; getline(inFile, info.date.month,' '); inFile >> info.date.day; inFile >> info.date.year; inFile >> info.renewal.months_left; //getline(inFile, info.date.day,' '); //getline(inFile, info.date.year,' '); //getline(inFile, info.renewal.months_left,' '); getline(inFile, info.renewal.month_1,' '); inFile >> info.renewal.day_1; //getline(inFile, info.renewal.day_1,' '); //inFile >> info.address.zip_code; //inFile >> info.date.day; //inFile >> info.date.year; //inFile >> info.renewal.months_left; //inFile >> info.renewal.day_1; inFile.ignore(INT_MAX,' '); return bool(inFile); } //void PrintHeadingOutput(ofstream& outFile) //{ // outFile
this is what the text file should look like after the code is finished.and this is what the terminal should look like
Open 2 Joe Saith(14) 3123 Abbey Road 4 Huntsville, Alabana narth 34563 S The last reneval notice was sent an March 19, 2082 644uOS Open 2 Joe Saith(14) 3123 Abbey Road 4 Huntsville, Alabana narth 34563 S The last reneval notice was sent an March 19, 2082 644uOSStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started