Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, 7th_zorro, dr_panther), 1,297 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 3 of 4 1 2 3 4
Re: multidimensional arrays as function arguments [Re: NeoNeper] #429432
09/12/13 11:44
09/12/13 11:44
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
@NeoNeper: yeah I think I'll ask there later, thanks laugh

I'm just extremely irritated 'cause everyone keeps saying it works without any problems...


POTATO-MAN saves the day! - Random
Re: multidimensional arrays as function arguments [Re: Kartoffel] #429436
09/12/13 12:17
09/12/13 12:17
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
ahh okay I see. earlier I had also this dimension issue, and I gave up using static mutlidimensional arrays. basically I use one-dim dynamic ones only.


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: multidimensional arrays as function arguments [Re: sivan] #429437
09/12/13 12:20
09/12/13 12:20
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
a workaround:

Code:
#include <acknex.h>

var vars[8][8];

void print_var(var *input_array, unsigned int index_x, unsigned int index_y)
{
	var output_var = input_array[index_x + 8*index_y];
	
	printf("array[%.0f][%.0f] = %.0f", (double)index_x, (double)index_y, (double)output_var);
}

void main()
{
	int i,j,k = 0;
	for(i = 0; i < 8; i++)
	{
		for(j = 0; j < 8; j++)
		{
			vars[i][j] = k++;
		}
	}
	
	print_var(vars, 3, 3);
}


Last edited by sivan; 09/12/13 12:26.

Free world editor for 3D Gamestudio: MapBuilder Editor
Re: multidimensional arrays as function arguments [Re: sivan] #429440
09/12/13 12:27
09/12/13 12:27
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
you could try var=&array[x][x] or similar perhaps


Compulsive compiler
Re: multidimensional arrays as function arguments [Re: Wjbender] #429443
09/12/13 12:43
09/12/13 12:43
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
thanks for the suggestions.

would it work if I create a pointer array inside the function 'print_var' and just pass the address of the var array 'vars'?


POTATO-MAN saves the day! - Random
Re: multidimensional arrays as function arguments [Re: Kartoffel] #429444
09/12/13 12:51
09/12/13 12:51
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
I tried a couple of things, but the only working I found is the one I posted above. but I would be happy to see a real solution laugh


Free world editor for 3D Gamestudio: MapBuilder Editor
Re: multidimensional arrays as function arguments [Re: sivan] #429449
09/12/13 13:09
09/12/13 13:09
Joined: Mar 2012
Posts: 927
cyberspace
W
Wjbender Offline
User
Wjbender  Offline
User
W

Joined: Mar 2012
Posts: 927
cyberspace
the method sivan used is inside the manual at variables you could define your multidimensional array as
array[200] //200=10*20.....

or pass the array inside of a structure..

typedef struct
{
var *myarray;
}mymultiarray;


Compulsive compiler
Re: multidimensional arrays as function arguments [Re: Wjbender] #429450
09/12/13 13:16
09/12/13 13:16
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
Kartoffel Offline OP
Expert
Kartoffel  Offline OP
Expert

Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
since the array size in my code is static (16³) I think I'll go with the first method.

Thank you all a lot, I'll let you know if it works.

edit: forgot to mention: you have to use the right order of the dimensions, so it would be:
var output_var = input_array[index_x * 8 + index_y];

Last edited by Kartoffel; 09/12/13 13:17.

POTATO-MAN saves the day! - Random
Re: multidimensional arrays as function arguments [Re: Kartoffel] #429455
09/12/13 15:11
09/12/13 15:11
Joined: Apr 2006
Posts: 159
Latvija
Arrovs Offline
Member
Arrovs  Offline
Member

Joined: Apr 2006
Posts: 159
Latvija
Just use one of my examples. They work great. And idea about giving pointer for one exact value to print is good too.


Arrovs once will publish game
Re: multidimensional arrays as function arguments [Re: Arrovs] #429703
09/17/13 01:00
09/17/13 01:00
Joined: Dec 2010
Posts: 224
NRW, Germany
NeoJones Offline
Member
NeoJones  Offline
Member

Joined: Dec 2010
Posts: 224
NRW, Germany
In the last days I has this problem, too. I would be happy for a real solution, too. I dont understand the examples of Arrovs...

Sorry for my bad english.


Errors are the engine of progress.

Version: A8 Commercial
OS: Win 7 64bit
Models: Cinema 4D
Page 3 of 4 1 2 3 4

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1