Hi there!
In my efforts to build some function that get an array from type integer ( =void func(int array[32][32])
But the compiler keep sending me weird errors. Tried several things like not defining the size of the array but it doesn't work...errors like invalid conversion of type 'int to int- [32]'
Pkease help!!!
kimkash:
Hi there!
In my efforts to build some function that get an array from type integer ( =void func(int array[32][32])
But the compiler keep sending me weird errors. Tried several things like not defining the size of the array but it doesn't work...errors like invalid conversion of type 'int to int1. [32]'
Pkease help!!!
Thanks and stuff..
[/quote]
In C/C++, arrays are second class citizens. Instead of passing the array, you are passing a pointer to the array, and the declaration is changed to be a pointer by the compiler. As others have mentioned, you likely don't have that much memory to hold a 32x32x2 byte array in an AVR based processor or 32x32x4 byte array in an Arm processor.
Hi again
so first-I'm running Arduino Mega 2560 Rev3 so the RAM isn't an issue for as long as if the array really takes 2048 and not more...the Mega Rev3 has 8kb of SRAM.
second,this is the code:
/* This program cycles through all the LEDs in a regular-multiplexed 3x3 LED matrix.
*/
int array[3][3]={{1,1,1},{1,1,1},{1,1,1}};
void setup()
{
for (int i=0;i<11;i+=2) pinMode(i,OUTPUT);
for (int i=0;i<5;i+=2) digitalWrite(i,LOW);
for (int i=6;i<11;i+=2) digitalWrite(i,HIGH);
pinMode(13,OUTPUT);
digitalWrite(13,LOW);
}
void loop()
{
refresh(array[3][3]);
delay(1000);
}
void refresh(int leds[3][3])
{
for (int i=0;i<3;i++)
{
for (int j=0;j<3;j++)
{
if (leds[i][j]==1)
{
digitalWrite(i,HIGH);
digitalWrite(j,LOW);
delay(50);
digitalWrite(i,LOW);
digitalWrite(j,HIGH);
}
}
}
}
As you'll try to compile,you'll see the error. try to correct it to any of the following
array
array[][]
array[][3]
array[3][]
array[3][3]
Thank your for your help!
and sorry the first Q was with a lot of spelling mistakes...wrote it via mobile during pickup to work...
No, it isn't. If you know that the array should contain n elements, say so. That way, the compiler will make sure it contains n elements. If you don't specify the size, and provide more or less initializers that you think you did, the compiler will supply missing ones or complain about extras.
For an array size of three, it's relatively easy to see that there are 3 initializers. For an array size of 300, it's a lot harder.