|
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
OP
Expert
|
OP
Expert
Joined: Jun 2009
Posts: 2,210
Bavaria, Germany
|
@NeoNeper: yeah I think I'll ask there later, thanks 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: sivan]
#429437
09/12/13 12:20
09/12/13 12:20
|
Joined: Mar 2011
Posts: 3,150 Budapest
sivan
Expert
|
Expert
Joined: Mar 2011
Posts: 3,150
Budapest
|
a workaround:
#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.
|
|
|
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
Wjbender
User
|
User
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
OP
Expert
|
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: sivan]
#429449
09/12/13 13:09
09/12/13 13:09
|
Joined: Mar 2012
Posts: 927 cyberspace
Wjbender
User
|
User
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
OP
Expert
|
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
Member
|
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
Member
|
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
|
|
|
|