文件读取问题,运行 时卡住没有输出

Problem with file reading, stuck without output when run

我正在尝试编写一个程序,从文件中读取数字,将它们输出到向量中,然后写入它们。代码编译得很好,但是当 运行 时,它会卡在提示符下而不会提供任何输出。

计划 LectorDeEnteros;

type 
    Arreglo = array [1..30] of integer;
var  
    //Arch:text;
    Prom:byte;
    i:integer;
    ArregloA:Arreglo;

Procedure CargadorVectorialdeArchivo (var ArregloA:Arreglo);
    var 
        Arch:text;
        i:integer;

Begin 
    assign (Arch,'Numeros.txt');
    reset (Arch);   

    i := 1;
    while not eof(Arch) do
        Write(Arch);Read(ArregloA[i]);
        i := i + 1;
End;

Begin 

    CargadorVectorialdeArchivo(ArregloA);


    for i := 1 to 14 do 
        WriteLn(ArregloA[i]:3);

End.

正如我所说,没有错误消息,只有提示,没有输出。我必须按 CTRL-Z 才能将其从 "loop" 中取出。预期的输出将是数组的数字,每行一个。

将程序重写为:

Procedure CargadorVectorialdeArchivo (var ArregloA:Arreglo);
    var 
        Arch:text;
        i:integer;

Begin 
    assign (Arch,'Numeros.txt');
    reset (Arch);   

    i := 1;
    while not eof(Arch) do
       begin 
        Read(Arch,ArregloA[i]); 
        i := i + 1;
       end;
End;

Arch 放在文件前面告诉编译器您要从该文件而不是键盘读取内容。