Taking forever to copy 2d array
So I have a function which takes in a 2d array as a parameter and sets its value by copying another (locally declared) 2d array like this (both 2d arrays of unsigned chars):
Code:
for (int tempcol=0;tempcol<4;tempcol++)
{
for (int temprow=0;temprow<4;temprow++)
{
charstate [temprow][tempcol]=tempstate[temprow[tempcol];
}
}
but this is massively slowing my program.
Doing this takes a fraction of the time:
Code:
unsigned char test=12;
for (int tempcol=0;tempcol<4;tempcol++)
{
for (int temprow=0;temprow<4;temprow++)
{
charstate [temprow][tempcol] =test;
}
}
Why is this? Any solutions to speeding up my application?
Thanks!