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.