I'm trying to pipe a structure from multiple child processes back to a parent. The structure
typedef struct node* Node;
struct node{
char *str;
int num;
struct node* next;
};
is set up as so. When i read/write with the pipe and try to print the structure fields out, it says my variable is requesting something from a structure but is not a structure.
wordc-mp-main.c:123:44: error: request for member ‘num’ in something not a structure or union
printf("%s, count %d\n", taken->str, taken->num);
^
Here is the pipe code from the Child processes:
close(fd[0]);
fclose(inputFile);
Node* pass = wordList->head;
write(fd[1], pass, sizeof(Node));
Here is the code from the Parent:
close(fd[1]);
Node* taken;
read(fd[0], taken, sizeof(Node));
printf("%s, count %d\n", taken->str, taken->num);
Please help and thank you.
update: removed * from the nodes and made the one
Node taken = (Node) malloc(sizeof(Node));
I get no segmentation faults, but my structure did not pass through the pipe correctly.