I need help on Editing Records!

Hey guys, recently, i've been working on a program for editing a specific entry inside a text file. The entry format in the text file is:

fscanf(fp,"%d %s %s\n", num, firstname, lastname);

here is the example for the records inside fp:

1 Benjamin Floyd
2 Benjamin Jeric
3 Polz Clara
4 Banawa Benny
5 Zamudio Jean

So far, i have done this code:
1
2
3
4
5
6
7
8
9
10
11
12
13
fp = fopen("source.txt", "r");
fp2 = fopen("tempedit.txt", "w");
fp3 = fopen("edit.txt", "w");
scanf("%d", search);
while(!feof(fp))
{
      fscanf(fp"%d %s %s", num, firstname, lastname);
      if (strcmpi(ln,ln1) != 0)
            fprintf(fp2,"%d %s %s\n", num, firstname, lastname);
      else
            fprintf(fp3, "%d %s %s\n", num, firstname, lastname);
}
//I finished up to here then i got stuck. 


supposedly, after picking out the desired record to edit, it should askk which part of the record to edit (e.i. lastname) and after the edit, the records in the tempedit.txt file should be put back with the edited one in the source.txt file(in its original order before it was edited). PLEASE GUYS. I REALLY NEED YOUR HELP! :(

p.s. you guys got any tip on how to make my program be cool-looking? like add symbols like shapes and stuff? Would be really great. YEAH :)) THANKS in ADVANCE!
You will need to rewrite the file as you can't amend a sequential file in the way you have in mind. So you may as well read the whole thing into memory, edit it, then write it out again.
@kbw
Lol thank! :) I found out a way to edit a record by just editing it before placing in a temp file. Thanks anyway dude :D
Topic archived. No new replies allowed.