passing arrays by reference
i new arduino, come c++ ground in microsofts vs. i trying pass array function reference, more 1 function can operare on same array. an example of i'm trying do:
at least in vs. how it, arduino returns error stating 'declaration of 'ary' array of references'. i'm not sure work around. so far have concluded prototype needed fix bug in arduino's auto-prototyping, , have found several postings saying can not return array function. anything help.
rigg
quote
void function(int &);
void setup(){
serial.begin(9600);
};
void loop(){
int counter[10];
funtion(&cunter[]);
for(int i=0;i<10;i++){
serial.println(counter);
}
};
void function(int &functionary[]){
for(int i=0;i<10;i++){
funtionary=(i*10);
}
}
at least in vs. how it, arduino returns error stating 'declaration of 'ary' array of references'. i'm not sure work around. so far have concluded prototype needed fix bug in arduino's auto-prototyping, , have found several postings saying can not return array function. anything help.
rigg
arrays (which pointers) pass reference default.

code: [select]
void function(int arr[]);
void setup(){
serial.begin(9600);
}
void loop(){
int counter[10];
funtion(cunter);
for(int i=0;i<10;i++){
serial.println(counter[i]);
}
}
void function(int arr[]){
for(int i=0;i<10;i++){
arr[i]=(i*10);
}
}

Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > passing arrays by reference
arduino
Comments
Post a Comment