How do I initialize an array of structures in C?
Your example_str is an array of 100 pointers to example structures. Initializing all these pointers to NULL, as you’ve done, is fine, but of course none of those null pointers will be usable until you set them to point to an existing struct example, e.g., example[i] = malloc( sizeof(struct example) ). If ex_field_2 only exists inside struct example, then your printf statement is invalid. It should be something like this: for (i = 0; i < 100; i++) printf("%d\n",example_str[i]->ex_field_2… Once again assuming you’ve initialized the example_str[i] pointer. You should think about whether you’re using struct example correctly. It looks like it might be a node in a linked list, since it contains a pointer to a struct example. In this case, you wouldn’t declare an array of pointers to struct example, but build a dynamically allocated linked list.