I have a "Server" and a "Client" process, they "communicate" through a struct shared memory.
typedef struct
{
char* buffer;
int cards;
int maxCards;
} myStruct
Both "Server" and "Client" processes can get/set the values of the two int types, but the thing is different with the buffer (we use this as a pointer to chars): the "Server" allocates memory, like:
(*sharedMem).buffer = (char*) malloc(sizeof(char)*maxCards);
has the ability to set or get values:
(*sharedMem).buffer[0] = 'a';
printf("%c\n",(*sharedMem).buffer[0]);
but when the "Client" process tries to access a char:
printf("%c\n",(*sharedMem).buffer[0])
It collapses with Segmentation Fault Core Dumped error. Is there a way to solve this problem without using an Array or List? Any Ideas?