Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Misc > Why does this w...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 740 of 792
Post > Topic >>

Why does this work? (SetLength)

by Dennis-Bendert Schramm <dennisschramm@[EMAIL PROTECTED] > May 28, 2007 at 04:31 PM

Hello,

I'm playing around with the SetLength function und I wonder why the 
following little test app works:

{01} program setlengthtest;
{02} var strarray:array of string;
{03}    i:word;
{04}
{05} begin
{06}    setlength(strarray,2);
{07}    strarray[0]:='1. String';
{08}    strarray[1]:='2. String';
{09}    strarray[2]:='3. String';
{10}    strarray[3]:='4. String';
{11}    strarray[4]:='5. String';
{12}    for i:=0 to 4 do writeln(strarray[i]);
{13} end.

To my understanding there should be an error in line 9, because the 
array index is exceeded.
If I compile this little app on MacOS X 10.4.8 with FPC 2.1.1 it seems 
to work just fine. So how to set a strict boundary of a dynamic array?

Any ideas?

Thanks in advance,

Dennis Schramm




 2 Posts in Topic:
Why does this work? (SetLength)
Dennis-Bendert Schramm &l  2007-05-28 16:31:07 
Re: Why does this work? (SetLength)
Wolf Behrenhoff <NoSpa  2007-05-28 19:39:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 15:07:11 CDT 2008.