I am reading a void* to a memory address from a pipe. The memory address is that of a char* as seen below.
char *text=getStringFromFunction(params);
void *adrs=&text;
write(pipefd[1], adrs, sizeof(char *));
Now I am trying to print out the text on the other side of the pipe, but I am unsure how to get a hold of the char* with only the memory address. This is all within the same process, so I believe I should be able to access the address space with just the pointer to it. Below is one of my attempts
void *buf;
read(pipefd[0], buf, sizeof(char *));
fprintf(stdout, "buf=%s", (char *) buf);
But it yields garbage results. Again, I could find nothing relevant to this topic on the search and Thanks for the help in advance!