Casting an array problem from unsigned int to uint8_t
Hi guys, Im facing a serious problem and I need your help please!
what Im facing is that Im getting value from another function as integer
which they are : so those value exactly I want to copy them to an array type uint8_t.
this means the array that I want to get is
Code:
uint8_t arr={5,1,2,3,4,5};
what actually the problem?
the problem is this if I want to initialize and array type uint8_t with those values then I write immediately in the compiler:
Code:
uint8_t arr={5,1,2,4,5};
(I mean by intilizing immediately ..once I write my syntax uint8_t arr in my compiler I write immediately )
the problem that those values Im getting them from other function ..and I want those values to be entered as it's in an array type uint8_t this means my array would be the same with those value but type uint8_t =>
Code:
uint8_t arr={5,1,2,3,4,5};
how can I do that ? I tried to use unsigned int and starting filling it with values but it didn't work!
any help how can I implement that? thanks alot.
what I mean by code is this:
Code:
int array2={5,1,2,3,4,5};
unit8_t array1[6]={0};
for(int i=0;i<(sizeof(array2)/sizeof(array2[0]));i++)
{
array1[i]=array[i];} /*I want the same values of array2 to enter to array1 but the type of array to be uint8_t*/
}
so what I expect to get once I print output is the array1 which it should be : and array1 type uint8_t with the same values that I copied them to it.
but the output is wrong answer, it's���a��ߙ��I��
any help please? thanks