I have a nested structure of this type -
typedef struct {
head HEAD;
tail TAIL;
start START;
end END;
}NODE;
I have a pointer to this nested structure -
NODE* settings = malloc(sizeof(NODE));
and I pass this pointer to nested struct to a function. In the function, I need to access the individual structs within the main struct, to add the bytes within the struct. This is the function prototype -
int checksumVerify( NODE* settings)
{
unsigned int i;
unsigned char checksum = 0;
//I need to access the size of individual structs from the pointer to main struct and then add all the bytes in the inner struct together.
for (i = 0; i < sizeof(*settings)->HEAD; i++)
{
checksum += (char)(settings)->HEAD;
settings++;
}
//Like wise I need to do it for the second struct as well
for (i = 0; i < sizeof(*settings)->TAIL; i++)
{
checksum += (char)(settings)->TAIL);
settings++;
}
return ((int)((checksum == 0) ? 1 : 0));
}
I do not know know the syntax to access the size of individual structs and accessing each entry in each of the individual struct is wrong here. What is the correct syntax for both?