I have a structure
typedef struct
{
unsigned char status;
unsigned char group_id;
unsigned char acc_trip_level;
unsigned char role[50];
unsigned char standard_panic_header[50];
unsigned char high_threat_message[50];
unsigned char high_threat_header[50];
}cfg;
cfg test_val;
I'm passing this structure as an argument to a function and How can I get/access the elements of structure by memory location(in other words i want to treat this structure by memory address)
void foo(cfg *ptr)
{
printf("%zu\n", sizeof(*ptr)); //Gives size of the strcture
printf("%p\n", (void*)ptr); //Gives the starting address of strcure
printf("%p\n", (void*)(ptr+4)); //I want to access the 4th element/ memorylocation
}
Is giving me the result
203
0x8049780
0x8049aac
But it should give 8048780+4 = 8048784 right.. am I missing something