Hi. I have some logic trouble (again) regarding the assignment of struct data type variables. E.g. 1: declaring a normal variable (var) of struct data type
1 2 3 4 5 6 7 8
//program in c
#include <stdio>
#include <stdlib.h>
struct a
{int x,y;} var;
int main(void)
{var=9;
return 0;}
This error shows up: incompatible types when assigning to type 'struct a' from type 'int'. which I totally agree and understand.
But when declaring a pointer variable and assign it to an address:
1 2 3 4 5 6 7
#include <stdio>
#include <stdlib.h>
struct a
{int x,y;} *var;
int main(void)
{var=0x28ff1c;
return 0;}
This doesn't give any error, as if 0×28ff1c is of type struct a, but this doesn't make any sense. Can you please explain me the logic in as much details as possible? Thanks in advance!