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

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




PostPosted: Sat Feb 18, 2006 5:47 pm   Post subject: Passing arrays

I don't know if this has been addressed in this forum; I gave up serching through the 63 pages of hits the search term "passing arrays" returned. Anyways, I'm writing a football game and I need to pass a 2D array to a procedure which will then write the contents of that array to a file. The I/O is no problem for me, but if anyone knows how to pass arrays please let me know.
Thanks
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Sat Feb 18, 2006 6:01 pm   Post subject: (No subject)

Welcome to CompSci.ca! Smile

You can pass an array into a procedure, like this:
code:

proc test (arr : array 1 .. 10 of int)

Of course, what if the array doesn't end at 10?
code:

proc test (arr : array 1 .. * of int)

This will accept an array with a lower bounds of 1 and an upper bounds of mostly anything.

A 2D array can be done like this:
code:

proc test (arr : array 1 .. *, 1 .. * of int)


Here's an example:
code:

proc test (arr : array 1 .. *, 1 .. * of int)
    put arr (1, 1)
end test

var my_arr : array 1 .. 5, 1 .. 3 of int
my_arr (1, 1) := 42

test (arr)
Delos




PostPosted: Sat Feb 18, 2006 11:00 pm   Post subject: (No subject)

Or do you mean parse? That would entail an analysis of each element and redistribution based upon their inherent structures as per your afore setup grammatical structure...Very Happy
Or something like that. Listen to Cervantes.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: