Allocating memory for a part of structure
问题 I have the following example #include <stdlib.h> #include <stdio.h> #include <stddef.h> typedef struct test{ int a; long b; int c; } test; int main() { test *t = (test*) malloc(offsetof(test, c)); t -> b = 100; } It works fine, but Im not sure about it. I think I have UB here. We have a pointer to an object of a structure type. But the object of the structure type is not really valid. I went through the standard and could not find any definition of this behavior. The only section I could find