1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

problem in deleting a record from a file...

Discussion in 'C' started by rakesh48019, Jul 31, 2008.

  1. rakesh48019

    rakesh48019 New Member

    Joined:
    Jul 31, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    hello frnds recently i was wrighting a prog using c
    i was trying to delete record from the an existing file......
    my record was of structure type ......but i was unable to do it.............:nonod:
    can any body give me the logic to delete this kind of record from a file??????
     
  2. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    You can't; there is no way to close up the gap freed by a deleted record, other than to copy all the records into a new file except the one you want to delete.
     
  3. rakesh48019

    rakesh48019 New Member

    Joined:
    Jul 31, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    ok bro, thanx 4 the info....... can u give me a small code of it......
    suppose i m using a structure as
    struct emp
    {
    int emp_code;
    int d_code;
    char emp_loc[25];
    char emp_name[30];
    };
    now can u wright a code 4 me to wright a 4 to five record in file say "emp" then delete one of a record from it??? :worried:
     
  4. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    No, I'm not going to write code for you for free, although if you're prepared to pay the going rate I might consider it. It's not difficult, where exactly are you stuck and how far did you get?
     
  5. rakesh48019

    rakesh48019 New Member

    Joined:
    Jul 31, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    actually i have written the prog.....according to ur logic........it is woriking for the first time only.......that is after adding & then printing the records when i m deleting it after that all the data gives garbage values:nonod: .......wat i vl do
     
  6. sofprog66

    sofprog66 New Member

    Joined:
    Jul 8, 2008
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    Guys you dont need to charge people for money to write a couple lines of code, its not like those couple lines of code will earn that person a shiz load of money. What you're doing is just basically helping them out and teaching them at the same time.
     
  7. xpi0t0s

    xpi0t0s Mentor

    Joined:
    Aug 6, 2004
    Messages:
    3,012
    Likes Received:
    203
    Trophy Points:
    0
    Occupation:
    Senior Support Engineer
    Location:
    England
    rakesh48019: OK, post what you've got so far, stripped down to show just the problem you're having, then we can see where you're going wrong and advise on where, why and possible solutions.

    sofprog66: many people post to forums trying to get people to write their code for them, because they're on a course and want to get through it with the minimal legwork, which is fine but they don't learn anything in the process, plus credit shouldn't go to them but to the person who actually wrote the code. On the other hand if they post what they've got then we can see where they're struggling, for example if they say "I'm allocating an array", you wouldn't necessarily see the problem, but if they show you the code "char *str1=malloc(20); char str2[] = { sizeof(str1) };" (I saw something similar to that just yesterday) you can see they've pretty much not got a clue about the syntax.
    Anyway if you think rakesh48019 will learn something by you writing the code for him (and maybe he will) then by all means go ahead and write it for him.

    rakesh48019: sorry if you're offended by any of the above. People can be very devious and say all sorts of stuff to try to get people to write code for them. So please don't take offence, just post your code and we'll help you solve the problem(s) with it.
     
  8. sofprog66

    sofprog66 New Member

    Joined:
    Jul 8, 2008
    Messages:
    29
    Likes Received:
    0
    Trophy Points:
    0
    xpi0t0s I meant no offence, I understand he needs to write some code in order to get some help. That should actually become a rule in this forum.
     

Share This Page