globalvar_read.c~

来自「Some simple source code to show specific」· C~ 代码 · 共 30 行

C~
30
字号
#include <sys/types.h>#include <sys/stat.h>#include <stdio.h>#include <fcntl.h>main(){int fd, num;fd = open("/dev/globalvar", O_RDWR, S_IRUSR | S_IWUSR);if (fd != - 1){	while (1)	{		read(fd, &num, sizeof(int));		printf("%d\n",num);		if (num == 0)		{			close(fd);			break;		}	}}else{	printf("device open failure\n");}}

⌨️ 快捷键说明

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