Return one array value - take array name from variable


hello, right trying this.


code: [select]
int give_number(char row[], int column){

int n0[]={1,1,1,1,1,1,1};
int n1[]={1,1,1,1,1,1,1};
int n2[]={0,1,1,1,1,0,1};
int n3[]={0,1,1,1,0,1,1};
int n4[]={1,1,1,1,0,1,0};
int n5[]={1,1,0,1,0,1,1};
int n6[]={1,0,1,1,1,1,1};
int n7[]={1,1,1,1,1,0,1};
int n8[]={1,1,1,1,1,1,1};
int n9[]={1,1,1,1,0,1,1};

return row[column];

}


i expect return row[column];

for example

code: [select]
int test=give_number("n2",2);

should output

code: [select]
test=1

but doesn´t work. output empty.

variable "names" don't exist @ run time. in fact, don't exist @ except in code. compiler turn references variable "names" storage places in memory.

you achieve similar using multi-dimensional arrays.



Arduino Forum > Using Arduino > Programming Questions > Return one array value - take array name from variable


arduino

Comments

Popular posts from this blog

DHT11 Time out error using v0.4.1library

Sketch upload fails with Java error (___REMOVE___/bin/avrdude)!

Arduino Uno + KTY81/210 temperature sensor