Untitled

 avatar
unknown
plain_text
3 years ago
505 B
5
Indexable
#include <stdio.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <string.h>
  
#define SEGSIZE 100

int main()
{
	int id_ftok = ftok("zad1.c",123);
	int id_shmget = shmget(id_ftok, SEGSIZE, IPC_CREAT | 0660 ); 
	if (id_shmget == -1)
		perror("shmget");
	
	char *attach_segment = shmat(id_shmget, 0, 0);


	strcpy(attach_segment, "pamiec wspoldzielona");


	printf("W pamieci wspoldzielonej znajduje sie: %s\n", attach_segment);

	shmctl(id_shmget, IPC_RMID, 0);	
	
	return 0;
}