⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test11_3.txt

📁 linux under the C programming which complementary with the book of <linux under the C programming
💻 TXT
字号:
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdio.h>

#define BUF_SIZE 1024
#define MYKEY 24

int main(void)
{
    	int shmid;
    	char *shmptr;
   
    	if(shmid=shmget(MYKEY, BUF_SIZE, IPC_CREAT)==-1)
    	{
        	printf("shmget error! \n");
        	exit(1);
    	}
    
	if((shmptr=shmat(shmid,0,0))==( void*)-1)
	{
    		fprintf(stderr,"shmat error!\n");
    		exit(1);
	}

	while(1)
	{
    		printf("string: %s \n", shmptr);
    		sleep(3000);
	}

	exit(0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -