I am very beginner in C. I have the following structure
typedef struct
{
zuint8 u8ZCLVersion;
#ifdef CLD_BAS_ATTR_LOCATION_DESCRIPTION
tsZCL_CharacterString sLocationDescription;
uint8 au8LocationDescription[16];
#endif
#ifdef CLD_BAS_ATTR_PHYSICAL_ENVIRONMENT
zenum8 u8PhysicalEnvironment;
#endif
#ifdef CLD_BAS_ATTR_DEVICE_ENABLED
zbool bDeviceEnabled;
#endif
} tsCLD_Basic;
now i want to set au8LocationDescription[16] field. And I am using this piece of code.
tsCLD_Basic sCombined;
sCombined.au8LocationDescription[16] = {0x42,0x65,0x64,0x20,0x52,0x6f,0x6f,0x6d};
but its shows error
error: expected expression before ‘{‘ token
how could I write the values..???
As the comment of Als says, what you are trying to do is not possible. You will need to assign each array element separately like this
and so on until each element is has the value you want.