#include #include #include #include #include int main() {int shmid,i; char *shmptr; /* Get a 10 byte shared memory segment */ shmid=shmget(getuid(),10,IPC_CREAT|0600); fprintf(stderr,"Shmem ID: %d\n",shmid); shmptr=shmat(shmid,0,0); strcpy(shmptr,"0123456789"); fprintf(stderr,"Shmem Contents: %s\n",shmptr); /* use realloc to change size */ realloc(shmptr,11); fprintf(stderr,"Shmem Contents after realloc: %s\n",shmptr); shmctl(shmid,IPC_RMID,0); }