💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
``` #include <sys/ipc.h> #include <sys/shm.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <stdio.h> #define SHMSIZE 128 int main() { key_t key = ftok(".", 1); int shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666); void *addr = shmat(shmid, NULL, 0); snprintf((char *)addr, SHMSIZE, "%s", "hello"); shmdt(addr); return 0; } ``` ``` #include <sys/ipc.h> #include <sys/shm.h> #include <sys/types.h> #include <unistd.h> #include <string.h> #include <stdio.h> #define SHMSIZE 128 int main() { key_t key = ftok(".", 1); int shmid = shmget(key, SHMSIZE, IPC_CREAT | 0666); void *addr = shmat(shmid, NULL, 0); printf("read from shm: %s\n", (char *)addr); shmdt(addr); shmctl(shmid, IPC_RMID, NULL); return 0; } ```