Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/types.h>
- #include <sys/ipc.h>
- #include <sys/shm.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #define MAX 10
- main(){
- int shmid, i;
- char *buf;
- char napis[10];
- const char *a = "aaaaa";
- const char *b = "bbbbb";
- shmid = shmget(45281, MAX*sizeof(int), IPC_CREAT|0600);
- if (shmid == -1){
- exit(1);
- }
- buf = (char*)shmat(shmid, NULL, 0);
- if (buf == NULL){
- exit(1);
- }
- while(1)
- {
- strcpy(napis,buf);
- if(0==strcmp(napis,a))
- printf("a\n");
- if(0==strcmp(napis,b))
- printf("b\n");
- putchar('\n');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement