write.c

来自「《linux驱动程序设计从入门到精通》一书中所有的程序代码含驱动和相应的应用程序」· C语言 代码 · 共 32 行

C
32
字号
/* * This file is subject to the terms and conditions of the GNU General Public * License.  See the file "COPYING" in the main directory of this archive * for more details. * * Copyright (C) 2007, 2010 fengGuojin(fgjnew@163.com) */ #include <sys/types.h>#include <sys/stat.h>#include <stdio.h>#include <fcntl.h>main(){	int fd;	char num[2];	int i=0;	fd = open("/dev/fgj", O_RDWR, S_IRUSR | S_IWUSR);	if (fd != - 1)	{                num[0]='F';		num[1]='G';		write(fd, num, 2);		close(fd);	}	else	{		printf("device open failure\n");	}	exit(0);}

⌨️ 快捷键说明

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