Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving text file from code

I have made this code:

Program Pzim ;
   var
     i:integer;
     vect:array[1..1001] of integer;
Begin
     i:=1;
     for i:= 1 to 999 do
     vect[i]:=i+1;
     for i:= 1 to 999 do
     writeln (vect[i]);
   readln;
End.

The program print a number sequence. I want to save in a text file what is printed.

it could be made using the Pascal yet or even using another source? Notepad++ maybe?

like image 694
h1k3rpath Avatar asked Apr 13 '26 16:04

h1k3rpath


1 Answers

Of course you can write to a text file in Pascal.

Program Pascal ;

var
  i:integer;
  vect:array[1..1001] of integer;
  Myfile: text;

begin
  i:=1;
  for i:= 1 to 999 do
    vect[i]:=i+1;

  Assign(Myfile, 'Myfile.txt');
  Rewrite(MyFile);

  for i:= 1 to 999 do
  begin
    WriteLn (vect[i]);
    WriteLn(Myfile, vect[i]);
  end;
  Close(Myfile);
  ReadLn;
end.
like image 177
Ken White Avatar answered Apr 16 '26 06:04

Ken White



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!