主题:文件类型问题
下题在显示器上输出时,总会死循环,请问是什么原因
(从键盘输入一段正文,将它复制到指定的磁盘文件中,然后再在显示器上输出。)
program p9_1(input,output);
var ch:char; str1:string[15];
file1:text;
begin
write('please input a file name:');
readln(str1);
assign(file1,str1);
rewrite(file1);
while not eof do
begin
while not eoln do
begin
read(ch);
write(file1,ch);
end;
readln;
writeln(file1);
end;
close(file1);
writeln;
reset(file1);
while not eof(file1) do
begin
while not eoln(file1) do
begin
read(file1,ch);
write(ch:3);
end;
readln;
writeln;
end;
close(file1);
end.
(从键盘输入一段正文,将它复制到指定的磁盘文件中,然后再在显示器上输出。)
program p9_1(input,output);
var ch:char; str1:string[15];
file1:text;
begin
write('please input a file name:');
readln(str1);
assign(file1,str1);
rewrite(file1);
while not eof do
begin
while not eoln do
begin
read(ch);
write(file1,ch);
end;
readln;
writeln(file1);
end;
close(file1);
writeln;
reset(file1);
while not eof(file1) do
begin
while not eoln(file1) do
begin
read(file1,ch);
write(ch:3);
end;
readln;
writeln;
end;
close(file1);
end.