我在我的 pascal 代码中在程序文件名之后和变量之前定义了一个新的字符串类型,但它给出了一个错误“开始”预期的 Str20 找到。
Program Input_try_1;
Type Str20 : string[20];
Var f: file of Str20;
x : String;
EOF : Boolean;
begin
EOF := False;
Assign(f,'Dic.txt');
Rewrite(f);
Writeln('When you finish enter <End>');
While EOF = false do
begin
Readln(x);
If x = 'End' then EOF := True
else Write(f,x);
end;
Close(f);
End.
我期待 'Type Str20:string[20]; 不会给出任何错误,并且无法理解问题。
在类型声明中,您使用等号而不是冒号,如下所示:
Type Str20 = String[20]
顺便说一句,您不需要定义自己的 EOF,您可以使用内置的 EOF 函数:
while not Eof(x) do ...
这样,您就不需要End
源文件中的 。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句