Question: can some help me with c++ code it not working #include #include #include #include using namespace std; void menu(void); void writeData(void); void readData(void); const char

can some help me with c++ code it not working

#include #include #include #include using namespace std; void menu(void); void writeData(void); void readData(void); const char FileName[] = "TestAddress.txt"; int main() { menu(); return 0; } //end of main function void menu(void) { char userChoice = ' '; do { cout << "(A)ppend Records, (S)how Records, (E)xit" << endl; cin >> userChoice; switch (userChoice) { case 'A': case 'a': // For appending the records writeData(); break; case 'S': case 's': // reading the records from file readData(); break; case 'E': case 'e'://For Exiting the program cout << "Exiting the program Now!" << endl; break; default: cout << "choice is Invalid" << endl; break; }; } while (userChoice != 'e'); } void writeData(void) { string name = " "; string street = " "; string city = " "; string state = " "; string zip = " "; char user_response = 'Y'; do { cout << endl; getline(cin, name); cout << endl << "Name..........."; getline(cin, name); cout << endl << "Street........."; getline(cin, street); cout << endl << "City..........."; getline(cin, city); cout << endl << "State.........."; getline(cin, state); cout << endl << "Zip Code......."; getline(cin, zip); ofstream MyFile(FileName, ios::app); if (MyFile.is_open()) { MyFile << endl << name << "," << street << "," << city << "," << state << "," << zip << endl; MyFile.close(); cout << endl << "Enter another Record? (Y/N)"; cin >> user_response; } else { cout << "File Error: Open Failed"; } } while (user_response == 'Y' || user_response == 'y'); } void readData(void) { string name = " "; string street = " "; string city = " "; string state = " "; string zip = " "; int recordCount = 0; ifstream MySavedFile(FileName); if (!MySavedFile.good()) { cout << " Unable to Open the file " << FileName << endl; return; } do { getline(MySavedFile, name, ','); if (MySavedFile.eof()) break; getline(MySavedFile, street, ','); getline(MySavedFile, city, ','); getline(MySavedFile, state, ','); getline(MySavedFile, zip, ' '); recordCount++; cout << " Record No. " << recordCount; cout << endl; cout << "Name.........." << name << endl; cout << "street.........." << street << endl; cout << "City.........." << city << endl; cout << "State.........." << state << endl; cout << "Zip.........." << zip << endl; cout << "_______________________________________" << endl; } while (true); MySavedFile.close(); cout << endl; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!