I have an int8 array essentially declared as a BYTE array at the top of my program.
I want to copy the contents of this array into char array for processing. The content in my byte array is as follows:
byte_array[0] = "A";
byte_array[1] = "Q";
byte_array[2] = "W";
byte_array[3] = "E";
byte_array[4] = "R";
byte_array[5] = "T";
byte_array[6] = "Y";
byte_array[0] = "Z";
byte_array[1] = ".";
byte_array[2] = ".";
byte_array[3] = ".";
And my code is as follows:
char char_array[];
for (j = 0; j < byte_array_size; j++) {
char_array = &byte_array[j];
printf("char_array[j]: %c - j: %u\n\r", char_array[j], j);
}
Note: j and byte_array_size are declared at the top of my program and are intialised with 0 and 10 respectively. byte_array has been populated as mentioned at the start of the post.
The printf above is essentially printing out spurious characters rather than:
char_array[0] = "A";
char_array[1] = "Q";
char_array[2] = "W";
char_array[3] = "E";
char_array[4] = "R";
char_array[5] = "T";
char_array[6] = "Y";
char_array[0] = "Z";
char_array[1] = ".";
char_array[2] = ".";
char_array[3] = ".";