Heloo guys... Once I try to run this code I am gettin an 'invalid pointer operation' error, what is the problem ? It is supposed to sort those names in that textfile into an alphabetical order (school project).
program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils, Classes;
var
names : TextFile;
count : integer=0;
array : array of string;
i : integer;
Procedure Load;
begin
Reset(names);
SetLength(array, count - 1);
for i := 1 to count do ReadLn(names, array[i]);
end;
begin
AssignFile(names, 'names.txt');
Reset(names);
While not EoF(names) do
begin
ReadLn(names);
Inc(count);
end;
Load;
for i := 1 to count do WriteLn(array[i]);
ReadLn;
CloseFile(names);
Erase(names);
end.
SetLength(Array, 0);- Jerry DodgeLength(array)instead. - Jerry Dodge