Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
410 B
1
Indexable
Never
#include<stdio.h>
#include<stdlib.h>
#include<sys/shm.h>
#include<unistd.h>
#include<string.h>
void main()
{
	char str[100];
	int shmid=shmget((key_t)2366,1024,0666|IPC_CREAT);
	printf("Key of shared memory is %d\n",shmid);                           
	void *shm=shmat(shmid,NULL,0);
	printf("Process is attached at %p\n",shm);
	read(0,str,100);		
	strcpy(shm,str);
	printf("Value shared is %s\n",(char*)shm);
}