S
Sally
I am confused as to why the code below does not produce a segmenation
fault. It actually works, and I get 12 outputted on my screen. I
would have thought I needed to get memory using malloc?
I noticed also if I do use malloc, then free(ptr), I can still use
ptr->z and assign to z successfully?
struct myStruct {
char x[10];
char y[1000];
int z;
};
int main(..) {
struct myStruct *ptr;
ptr->z = 12;
printf("%d",prt->z);
}
fault. It actually works, and I get 12 outputted on my screen. I
would have thought I needed to get memory using malloc?
I noticed also if I do use malloc, then free(ptr), I can still use
ptr->z and assign to z successfully?
struct myStruct {
char x[10];
char y[1000];
int z;
};
int main(..) {
struct myStruct *ptr;
ptr->z = 12;
printf("%d",prt->z);
}