I just learned file handling and now developing a restaurant management system with 2 different credentials(staff and admin) in c++. I keep facing 2 problems in the code for admin part although there is no error shown in the build log.
Problem 1: In admin page, when I enter 3 to delete staff using staff username, all the staff record will be deleted.
Problem 2: In admin page, when I enter 4 to check list of staff registered by username, the system will keep staying at the same page, the list will not be shown.
For deleteStaffByUsername: You open a file for reading called database.txt, and a file for writing called <username>.txt.
Then, you rename a file called temp.txt to database.txt. It appears you should be writing to temp.txt and not <username>.txt. (Or the other way around, but point is, it's not consistent.)
For checkListOfRegisteredStaff: First thing I would do is make sure that the file you open on line 48 is successfully opened. Actually, this applies to both functions in question. I bet it's not opening the file correctly (which it expects to be the name of a username, and without any explicit extension). i.e. the file doesn't exist.