Question
Hi! I writing code for my scholl project, Its for small business there is a function to fire employee In Employee.txt each employee's information is
Hi! I writing code for my scholl project, Its for small business
there is a function to fire employee
In "Employee.txt" each employee's information is written on one line as in the picture
It should read "Employee.txt" and delete the line which employee's name I entered
with this code Its only delete the employee's name not delete the line which contain employee's info(last name and id)
Can u help me to fix this please?
void fire_employee(){ string deleteline; string line; ifstream emp; emp.open("Employee.txt"); ofstream temp; temp.open("temp.txt"); cout > deleteline; while (getline(emp,line)) { line.replace(line.find(deleteline),line.length(),""); temp
}
temp.close(); emp.close(); remove("Employee.txt"); rename("Employee.txt","temp.txt"); }
I'm expecting a result like in the pictures
--Employee Management Menu-- 1. Add new employee 2.Delete employee 3.Modify employee Choose an operation : 2 Which Employee do you want to fire? Employeel *Employee - Not Defteri Dosya Dzen Biim Grnm Yardm Employee1 LastName1 ID201402 Employee2 LastName2 ID432512 Employee3 LastName3 ID124136 St 2, Stn 29 100% Windows (CRLF) UTF-8 *Employee - Not Defteri Dosya Dzen Biim Grnm Yardm Employee2 LastName2 ID432512 Employee3 LastName3 ID124136 St 1, Stn 1 100% Windows (CRLF) UTF-8Step 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