Advertisement
Guest User

odczytuje

a guest
May 24th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. #include <sys/types.h>
  2. #include <sys/ipc.h>
  3. #include <sys/shm.h>
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include <string.h>
  7. #define MAX 10
  8.  
  9. main(){
  10. int shmid, i;
  11. char *buf;
  12. char napis[10];
  13. const char *a = "aaaaa";
  14. const char *b = "bbbbb";
  15. shmid = shmget(45281, MAX*sizeof(int), IPC_CREAT|0600);
  16.  
  17. if (shmid == -1){
  18. exit(1);
  19. }
  20.  
  21. buf = (char*)shmat(shmid, NULL, 0);
  22. if (buf == NULL){
  23. exit(1);
  24. }
  25. while(1)
  26. {
  27. strcpy(napis,buf);
  28. if(0==strcmp(napis,a))
  29. printf("a\n");
  30. if(0==strcmp(napis,b))
  31. printf("b\n");
  32. putchar('\n');
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement