-
memory and structs..
if i have a header fiel containing hte following..
Code:
#define TERMINAL_1 0x01
#define TERMINAL_2 0x02
typedef struct data {
int cookie;
int monster;
} D;
and if i ran two processes that ran this code.. how is it possible to set the first process (terminal1)'s cookie to 1, and the second process (terminal2)'s cookie to value 2.
how could i do that?
i've tried
Code:
TERMINAL_1->cookie = 1;
but this doesnt work.. any ideas?
-
Do some research on shared memory.
-
My first post here.. :)
you should make assignments after the right declarations, it works fine for me. hope this helps.
-
First of all, you're using a macro that's #defined as a pointer to something of type data, but the #define is actually an integer.
Remember the TERMINAL_1 macro will be replaced with 0x01, which means you'll have the following code being compiled:I shouldn't have to tell you that the literal value '1' isn't of type "pointer to data" :) So no, your code will not work.
Based on what you've posted, I think you need to read up some more on some basic C principles, and get more familiar with the language before attempting interprocess communication. When you're more familiar with things, then perhaps read up on shared memory and interprocess comms using something like pipes.
Good luck.