Why when I want to initialize the following vector of uint8_t
uint8_t *mmac_source1 = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 };
I get this error
Error: scalar object 'mmac_source1' requires one element in initializer
But when I am using this :
uint8_t mmac_source1[6] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 };
it's working fine.
uint8_t *mmac_source1 = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 };
Here you don't memory allocated to the pointer.
mmac_source1
just acts as a place holder wherein you can store an address.
uint8_t mmac_source1[6] = { 0x01, 0x80, 0xc2, 0x00, 0x00, 0x01 };
Here you have an array where in your compiler allocates sizof(uint8_t)*6
bytes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With