Lets pretend we have the following code:
typedef struct
{
int a1;
int a2;
} a_struct;
int prev (int a2)
{
int* p = &A_STRUCT-4;
return *p;
}
int main(void)
{
a_struct aStruct[] = {5, 10}; // Array-type initializing
printf("aStruct.a1 = %i", prev(aStruct->a2));
return 1;
}
I am trying to access aStruct.a1
's value by accessing aStruct.a2
memory address and dereferencing it, however following this way, it leads to an u/b and runtime complications.
With one word, it doesn't work. What am i doing wrong?