Change sub array data in one?

I have an array...
byte Test[4][8]={{2,4,16,32,63,65,127,64},{2,4,16,32,63,65,127,64},{1,3,7,15,31,63,127,255},{0,0,0,0,0,0,0,0}};
and later wish to change one sub array...
Test[1] = {27,3,19,31,53,5,12,60};
does not work and gives 'expected primary expression before { token.
Will somebody please suggest the correct syntax other than addressing each element in turn and changing data.
Thanks

donone:
Will somebody please suggest the correct syntax other than addressing each element in turn and changing data.
Thanks

That's how you would do it. You could throw memory at the "problem" and declare a constant array of the new values and use memcpy

So say you want to change this sub array,

byte Test[4][8]={{2,4,16,32,63,65,127,64},{2,4,16,32,63,65,127,64},{1,3,7,15,31,63,127,255},{0,0,0,0,0,0,0,0}};

with Test[1] = {27,3,19,31,53,5,12,60};

Well you will need to address each element in turn and change the data accordingly.

However, you might be able to use pointers to change each element.

byte myarray[8] = {27,3,19,31,53,5,12,60}; // make sure the size of the elements match.

Test[1] = *myarray;

This might work, but Im not 100% certain.

HazardsMind:
However, you might be able to use pointers to change each element.

byte myarray[8] = {27,3,19,31,53,5,12,60}; // make sure the size of the elements match.

Test[1] = *myarray;




This might work, but Im not 100% certain.

No, arrays are not modifiable like that ( remove * from myarray, but still illegal ).

Arduino can work with 64-bit numbers which are 8 bytes, so you can re-create the array like this:

union UINT64{ 
  unsigned char Data[8];
  uint64_t Int;
};

UINT64 Test[ 4 ] = {{2,4,16,32,63,65,127,64},{2,4,16,32,63,65,127,64},{1,3,7,15,31,63,127,255},{0,0,0,0,0,0,0,0}};

void setup() {
  Test[0].Int = 0x8899AABBCCDDEEFFULL;  //64-bit value, ULL is 'unsigned long long' specifier.
}

I know what the OP said, but why not just use a for loop to copy in the new values from another array ?
Easy to write, easy to maintain and best of all, easy to understand. By all means turn it into a function so that it can be used easily more than once, but why use an obscure method when a clear one will do ?

The structure alternative is almost the same, nothing really obscure about either though.

struct U64{
  void Set( void *v_Data ){ 

    byte *b_Data = ( byte* ) v_Data;

    for( char i = 0 ; i < 8 ; ++i )
      Data[ i ] = b_Data[ i ];
  }
  unsigned char Data[8];
};

U64 Test[ 4 ] = {{2,4,16,32,63,65,127,64},{2,4,16,32,63,65,127,64},{1,3,7,15,31,63,127,255},{0,0,0,0,0,0,0,0}};

void setup() {
  byte myarray[8] = {27,3,19,31,53,5,12,60};

  Test[0].Set( myarray );
}

donone:
Will somebody please suggest the correct syntax other than addressing each element in turn and changing data.

That is the simplest approach. Alternatively you can use memcpy to copy the entire block of memory to update the whole sub-array in one go - it's just another way of writing code to achieve the same end result.

If the performance cost of doing this was very high (i.e. you're doing it a lot and it's taking too much time) then you could change your data structure so that the outer array is an array of pointers rather than an array of arrays. Then you can just update any of those pointers to refer to a different array. However, the code would be less obvious and I wouldn't recommend bothering with that unless you had a performance problem.

@UKHeliBob: Time. I thought it looked like it would be fast (if it had worked). This is in an interrupt routine.
@HazardsMind: Same as above, I dislike loops if I can avoid their overhead.
@pYro_65: I still see that loop in there despite the final elegant and short line.
Perhaps I should declare, destroy and re=declare the array as your suggested struct U64.
I already have several loops manipulating data before the next 14mS interrupt.
Thank you all for letting me know my attempt won't work.

ps @PeterH: That sounds good but a bit beyond my reach. To me pointers are a phobia like spiders.

Wanting to do it fast I can understand, but do you absolutely have to do it in the ISR ? Could you not set a flag in the ISR and make the change in the normal code ? There is, of course, no guarantee that however you do it, that the compiler will not turn it into the same code anyway.

@UKHeliBob: You are absolutely right about outside the ISR.
The ISR sends the data and manipulates. My difficulty was that I could not solve how to calculate once only per interrupt. I cannot place the manipulation code in loop() because it repeats. If I call a routine from the ISR the code might as well be in the ISR. How do I trigger the calculations to take place and where?
If you can tell me how to do that it will mean I asked the wrong question for the wrong reason, and the problem will be solved.

In the ISR set a variable to true if the change should be made. Then, in loop() check the variable, make the change if it is true then set the variable to false.

Thank you UKHeliBob, problem solved. Why didn't I think of that? Don't answer.

for what it's worth, dit a little test. This works however:

// Do not remove the include below
#include "pointertest.h"
//
// 2 dimensional array
///
int array1[2][4] = {{1,2,3,4},
					{5,6,7,8}};
//
// make the assignment straight away
// otherwist it doesn't seem to work
//
int *ptr1 = array1[0];		// pointer to array

void setup()
{
	char str[10];		// string for sprintf
	Serial.begin(9600);
	//
	// loop through the array
	//
	for (int i = 0; i<8; i++){
		sprintf(str, "\r\n%3d", ptr1[i]);
		Serial.write(str);
	}
}

// The loop function is called in an endless loop
void loop()
{
//Add your repeated code here
}

@nicoverduin:
Thank you for that pointer, pointer. That is worth playing with at the least for learning more.