You are not logged in.
Pages: 1
I have created a shared memory segment (which size is 64 bytes) using shmget, shmat e.t.c and i want to divide it into 2 areas. One area for input data and one area for output? How can i do that?
Furthermore, When i have to write my input data into the shared memory segment i want to write something like this:
{a text messase, an integer, another integer}
Which function of c should i use? If i had to write only a text message and read it from another process i would use memcpy, but now i have the text messase and two integers (which i use as flags in my code).
Offline
struct myStruct {
char textMessage[16];
int int1;
int int2;
};
struct myStruct tmp;
strcpy(&tmp.textMessage, "hello");
tmp.int1 = 5;
tmp.int2 = 15;
memcpy(sharedMemoryArea, &tmp, sizeof(tmp));
Offline
Jeremy, i know it's 9 years later but your response perfectly fit what I was looking for. Thanks!
Pages: 1