该计划有什么问题? [英] What's wrong with the program?

查看:102
本文介绍了该计划有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,以下程序打开一个文件,并将第一行中存在的前两个字符串读入两个变量。问题是我一直试图看看下面的程序有什么问题,但我不明白为什么它不起作用。

编译器编译它没有任何问题,但是当我运行它时,它说退出exincode 2.

问题是该文件存在。

看起来有什么问题?

有谁可以请帮助?



这是代码。

Hello, well, the following program opens a file and reads the first two strings that exist in the first line into two variables. The problem is that I’ve been trying to see what’s wrong with the following program, but I can’t see why it’s not working.
The compiler compiles it without any problem, but when I run it, it says exited with exitcode 2.
The problem is that the file exists.
What seems to be the problem?
Can anyone please help?

This is the code.

Program num;

Var
f:Text;
b,g:String;
c:String[1];

Procedure thenum (a:String);
Begin
Assign(f,'textfileoffile.txt');
Reset(f);
a:='A';
while not eof(f) and (a<>' ') do
begin
Read (f,a);
End;
Writeln(a);
End;

Procedure sth ( j:String);
begin
Assign(f,'textfileoffile.txt');
Reset(f);
j:='A';
while not seekEoln and eof(f) do
begin
read(f,j);
end;
Writeln(j);
End;


begin
Assign(f,'textfileoffile.txt');
repeat
Reset(f);
until eof(f);
thenum (b);
read(f,c);
sth (g);
if eof(f)then
Close(f);
Readln;
End.

推荐答案

引用:

重复

重置(f);

直到eof(f);

repeat
Reset(f);
until eof(f);

此序列对我来说看起来不对。

This sequence looks wrong to me.


我这样写了,只打开文件一次,只在主程序中,

就在那里。

节目编号;



Var

f:文字;

b,g:字符串;

c:String [1];



程序thenum(a:String);

开始

分配(f,'textfileoffile.txt');

重置(f);

a:='A';

而不是eof(f)和(a<>'))

开始

读取(f,a);

结束;

Writeln(a);

结束;



程序sth(j:String);

开始

分配(f,'textfileoffile.txt');

重置(f);

j:='一个';

而不是seekEoln和eof(f)do

开始

读(f,j);

结束;

Writeln(j );

结束;





开始

分配(f,' textfileoffile.txt');

重复

重置(f);

直到eof(f);

thenum(b);

读(f,c);

sth(g);

如果eof(f)则

关闭(f);

Readln;

结束。
I wrote it like that, so as to open the file once, only in the main program,
there it is.
Program num;

Var
f:Text;
b,g:String;
c:String[1];

Procedure thenum (a:String);
Begin
Assign(f,'textfileoffile.txt');
Reset(f);
a:='A';
while not eof(f) and (a<>' ') do
begin
Read (f,a);
End;
Writeln(a);
End;

Procedure sth ( j:String);
begin
Assign(f,'textfileoffile.txt');
Reset(f);
j:='A';
while not seekEoln and eof(f) do
begin
read(f,j);
end;
Writeln(j);
End;


begin
Assign(f,'textfileoffile.txt');
repeat
Reset(f);
until eof(f);
thenum (b);
read(f,c);
sth (g);
if eof(f)then
Close(f);
Readln;
End.


非常感谢,现在程序,完全没有任何问题。
Thank you very much, the program now, works without any problem at all.


这篇关于该计划有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆