Deleting a Record in a Data File

How do I go about deleting a record from a data file? I haven't used classes and my textbook only shows me how to delete a record from a data file using objects in classes. please help me out!
Thanks in advance :)

I want to let the user enter a record number and delete it, if it exists. I'm not able to understand how to delete the record without using classes. This is what I've done so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void EditSal()
{   int recno1;
    std::cout<<"\n \n 1. Delete a Record \n 2. Modify a Record \n PLEASE ENTER THE NUMBER : ";
    std::cin>>no;
    switch(no)
    {
        case 1 : rfile.open("Salary.txt", ios::in, ios::out);
                 char found='f', confirm='n';
                 std::cout<<"\n DELETE A RECORD \n Enter The Record Number : ";
                 std::cin>>recno1;
                 for(i=0; i<recno; i++)
                     {
                       rfile>>recno;
                     }
    }
Menu();
}


And there's another doubt that I have. Can I use a single data file to store 13 variables and read only the values that I need? For eg:- If I have 4 variables name, age, salary and IT and store them in that order, can I just read name and IT?
Last edited on
Topic archived. No new replies allowed.