Multi dimensional arrays passed into a function
#1

I currently have an array such as this:

Code:
new Float:Hello[6][2] = {
    {1234.1211,1854.0146},
    {1564.4543,1564.1547},
    {1224.4215,1511.1113},
    {1133.1123,1112.4148},
    {1134.8743,1644.1546},
    {1154.4445,2124.1544}
};
(Note that all values are just random for the purpose of this post)


How do I call it in a function and then loop through all the values, such as:

Code:
public Random(Hello) {
}
I have tried defining it as

Code:
public Random(Float:RandomVariable[][]) {  
}
The above does allow me to pass the array into the function, however since there is no definate size of the passed array, it causes errors when trying to read the values with a loop. Since, I can't use sizeof(), I don't know how I can read all of the values Of an undetermined array size.

If I make it loop through a set number of times:

Code:
public Random(Float:RandomVariable[][]) {
	for(new i=0;i < 10;i++) {
		printf("%d - %f,%f",i,RandomVariable[i][0],RandomVariable[i][1]);
	}
	print("HELLO");
}
the server crashes when i == 6

Basically, How do I get all the values from a multi dimensional array when the array that is passed can differ in size?
Reply


Messages In This Thread
Multi dimensional arrays passed into a function - by rannandaman - 27.01.2011, 23:44
Re: Multi dimensional arrays passed into a function - by Krx17 - 27.01.2011, 23:51
Re: Multi dimensional arrays passed into a function - by Rachael - 27.01.2011, 23:54
Re: Multi dimensional arrays passed into a function - by rannandaman - 27.01.2011, 23:54

Forum Jump:


Users browsing this thread: 1 Guest(s)