• Domingo 28 de Abril de 2024, 22:52

Autor Tema:  Leer Un Documento .txt  (Leído 1831 veces)

keseki

  • Nuevo Miembro
  • *
  • Mensajes: 1
    • Ver Perfil
Leer Un Documento .txt
« en: Viernes 27 de Agosto de 2004, 18:09 »
0
Perdonen las molestias, estaba buscando un codigo para poder leer un documento .txt para poder utilizar su contenido dentro del programa, y despues sacarlo ordenado.
Muchas gracias.

gandalfelgris

  • Miembro activo
  • **
  • Mensajes: 53
    • Ver Perfil
Re: Leer Un Documento .txt
« Respuesta #1 en: Lunes 6 de Septiembre de 2004, 12:56 »
0
Hola Keseki,
                  Aqui te envio un codigo para leer un fichero de texto caracter a caracter y guardarlo en un vector.

with Ada.Text_Io;
use Ada.Text_Io;
procedure Leer_fichero is
f:File_Type;
C:Character;
i:integer:=0;
begin
Open (f,In_File,"nombre_Fichero.txt");
while not End_Of_File(f) loop
  while not End_Of_LIne(f) loop
    get (f,C);
    i:=i+1;
  end loop;
end loop;
declare
  type Vector_Numeros is array (1..i) of integer;
  Vect:Vector_Enteros;
  i:=1;
  while not End_Of_File loop
    while not End_Of_Line loop
      get(f,C);
      vect(i)=Character'Pos©-Character'Pos(0);
      i:=i+1;
    end loop;
  end loop;

Deberia funcionar esto

Atentamente
gandalfelgris