5 AnswersNew Answer
Max, Why are you using a `union` in that data structure? I don't understand what's the need of a `union` there ...
You should include string.h and use strcpy to assign value to char array
Your error has nothing to do with dynamical memory allocation. The error is that you're trying to assign a value to an array. char job_description; (people + i)->employee.job.job_description = "Dev"; Check this simple snippet: // You can initialize an array with string literal: char array = "Dev"; // But you can't assign it: array = " Hi Dev"; // Compile-time error: assignment to expression with array type One way to fix this is by using pointer: Change char job_description; Into: char* job_description;
I just wanted to see how to work with an union inside a structure. I could also put this as a string inside the structure, but I just wanted to see how it works inside.
Btw, thanks to all replies, now I got it.