Hi everybody,
I have a project to do for the college, which has to insert, read, delete and modify records in a binary file (a address book or something else). I don't know yet how I'll do to alter the records. Let's suppose the I have the program below:
program teste;
uses CRT;
type
reg = record
id:integer;
nome:string[30];
end;
var
arquivo: file of reg;
dados:reg;
begin
end.
The user will enter the id he wants to alter, i have done it this way, but it truncate the file at the current position:
while not eof(arquivo) do
begin
read(arquivo,dados);
if (dados.id = new) then
begin
dados.id:=new;
write(arquivo,dados);
break;
end;
end;
Could somebody help me with this?
Thanks in advance.