// daffy.c // by Michael Collins // #include #include #include #include #include int main() { key_t shkey; int shared_id; char* sharedmem; shkey = ftok("/dev/null",'A'); // Get the key to the shared segment set up by Bugs if( (shared_id = shmget(shkey, 0, 0)) < 0) //Get the id for the shared segment perror(NULL); if( (sharedmem = shmat(shared_id, 0, 0)) < 0) //Map segment onto our virtual space perror(NULL); printf("Bugs says its %s\n", sharedmem); sprintf(sharedmem,"Rabbit Season"); printf("But I, Daffy, say its %s\n", sharedmem); shmdt(sharedmem); //Unmap the shared segment }