Can you dynamically resize an array?
rolypolyman_at_gmail.com
Date: 01/20/05
- Next message: Bruce Roberts: "Re: Can you dynamically resize an array?"
- Previous message: VBDis: "Re: Converting a userspecific VCL-component to an ActiveX-control"
- Next in thread: Bruce Roberts: "Re: Can you dynamically resize an array?"
- Reply: Bruce Roberts: "Re: Can you dynamically resize an array?"
- Reply: Jamie: "Re: Can you dynamically resize an array?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 20 Jan 2005 14:48:46 -0800
To anyone --
What do you do when you're dealing with arrays whose size you
can't predict? Take the following illustrative example:
var
myarray : array[1..400] of integer;
mystring : string;
myinteger, errx : integer;
begin
assignfile(infile,'c:\myfile');
reset(infile);
while not eof(infile) do
begin
readln(infile,mystring);
val(copy(mystring,10,4),myinteger,errx);
inc(x);
myarray[x] := myinteger;
end;
..... do something with myarray[]
end;
How do you handle this when you can't predict how many lines of
text will be in the file? What if the user has a file containing
8000 lines of data?
It would be nice to allocate only a small amount of memory and have
the array automatically resize itself as it goes. How is this
usually done? I know I can work with pointers, too, but I'm not
clear on how to automatically resize those either.
Thanks,
RPM
- Next message: Bruce Roberts: "Re: Can you dynamically resize an array?"
- Previous message: VBDis: "Re: Converting a userspecific VCL-component to an ActiveX-control"
- Next in thread: Bruce Roberts: "Re: Can you dynamically resize an array?"
- Reply: Bruce Roberts: "Re: Can you dynamically resize an array?"
- Reply: Jamie: "Re: Can you dynamically resize an array?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|