I was struggling to fix a code today, then I come across something similar to:
typedef struct { int a; int b; int c; int d; char* word; } mystruct; int main(i
When you allocate memory for structptr, the pointer word in the struct has no valid memory to point. So you either malloc a piece of memory for word, too, or make word point to another character.
structptr
word
struct
malloc