void addWorkerToProject(Worker *worker, Project *project) {
worker->projects = malloc(sizeof (strlen(project)+1));
worker->projects[worker->projectCount]->name = project->name;
worker->projectCount++;
}
struct Worker
char *name;
Project **projects;
int projectCount;
struct Project
char *name;
Worker **workers;
int workerCount;
FeatureNode *features;
How do I make this function run correctly? It supposed to assign workers to project, but it fails to assign 2 projects to the same worker.
Let's say I have a worker named Sean and two projects name first and second. I need to attach them to Sean so for example when I print workers[i]->projects[j]->name they both needs to appear, when each iteration adds him 1 project. When I run it the first iteration is correct but the second one doesn't work.
(strlen(project->name) + 1) * sizeof(Project*)makes no sense. Why do you want to multiply the string length with the size of a pointer (which will likely always be8)? And if you want to copy a number ofProjectstructures, you need a loop.