Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 declaring arrays
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Blade




PostPosted: Thu Apr 03, 2003 7:03 pm   Post subject: declaring arrays

i was wondering if you could redeclare arrays... such as you declare an array with 3 elements, then you want to make it bigger, could you redeclare it with 5 elements... and if you cant, how can you do it?
Sponsor
Sponsor
Sponsor
sponsor
Catalyst




PostPosted: Thu Apr 03, 2003 7:34 pm   Post subject: (No subject)

you would have to declare it as a flexible array

code:


var names:flexible array 1..1 of string



to change the upper parameter...

code:


new names,5 %% 5 is the new max

Blade




PostPosted: Thu Apr 03, 2003 7:35 pm   Post subject: (No subject)

ah ic... this is gonna be so sweet, thanks a lot catalyst
Tony




PostPosted: Thu Apr 03, 2003 8:36 pm   Post subject: (No subject)

yea.. or you can just declear it to be big to begin with Wink

C++ doesnt allow dynamic arrays (array range must be known at compile time). Thats why they usually give you rangest on contests such as CCC ("test data will have up to 100 numbers" - so dim array as 100).

but thats C++... though turing is compiled in C++, so I dont think your flexible array will increase program performance... I'd like someone to correct/backup on that though
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: