K
K
Kostylev20212021-06-02 11:55:05
Pascal
Kostylev2021, 2021-06-02 11:55:05

Is the result not being written to a file?

There is a code according to which you need to check the match between the file first and massive and write the result to rezult
here is the code

var 
 first,massive,rezult: text ;
 str1,str2:string;
 i,n,t,y:integer;
 begin
 AssignFile(first,'c:\way\first.txt');
 reset(first);
 AssignFile(massive,'c:\way\massive.txt');
 reset(massive);
 AssignFile(rezult,'c:\way\new.txt');
 
 while not EOF(first) do
 begin
 Readln(first,str1);
 while not EOF(massive) do
 begin
 Readln(massive,str2);
 y:=pos(str1,str2);
 if (y<>0)then
 begin 
 rewrite(rezult);
 
 writeln(rezult,str2);
 end ;
 end;
 end;
 close(first);
 close(massive);
 close(rezult);
 end.

I even run it step by step like everything should work, but the result is not written to the rezult file?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
H
HemulGM, 2021-06-02
@HemulGM

rewrite(result); - reopens the file, clearing it. You do it in a loop every time

K
Kostylev2021, 2021-06-02
@Kostylev2021

Found an error, the path to the rezult file is not correct

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question