欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標(biāo)題: 一段進(jìn)程 [打印本頁(yè)]

作者: fucuhost    時(shí)間: 2018-11-2 07:27
標(biāo)題: 一段進(jìn)程
  1. #include <stdio.h>

  2. #include <unistd.h>

  3. #include <sys/ipc.h>

  4. #include <sys/shm.h>

  5. #include <sys/types.h>

  6. #include <string.h>


  7. #define BUF_SIZE 100


  8. int main()

  9. {

  10.         key_t key = ftok(".", 11);

  11.         int iShmID = shmget(key, BUF_SIZE, IPC_CREAT | 0666);

  12.         if (-1 == iShmID)

  13.         {

  14.                 return -1;

  15.         }

  16.         printf("shmget ok\r\n");

  17.        
  18. void *p = shmat(iShmID,NULL,0);

  19.         if (NULL == p)

  20.         {

  21.                 //delete

  22.                 return -1;

  23.         }

  24.         int i = 0;

  25.         char *p1 = (char *)p;

  26.         for (i=0;i<10;i++)

  27.         {

  28.          printf("%c ", p1[i]);

  29.         }

  30.         printf("\r\n");

  31.         shmdt(p);

  32.         printf("ok\r\n");

  33.         shmctl(iShmID,IPC_RMID, NULL);

  34.         return 0;

  35. }
復(fù)制代碼







歡迎光臨 (http://m.raoushi.com/bbs/) Powered by Discuz! X3.1