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

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 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-8

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!