test1.c
来自「MINIX操作系统的内核修改补丁」· C语言 代码 · 共 36 行
C
36 行
#include <stdio.h>#include <unistd.h>#include <fcntl.h>void main(){ int fd, r; char buf[32]; fd = open("data", O_CREAT | O_IMMED | O_RDWR); if(fd < 0) { printf("Fail to file open\n"); return; } r = write(fd, "This is an immediate file", 8); r = write(fd, "0123456789ABCDEF\0", 16); printf("File write: %d\n", r); close(fd); fd = open("data", O_RDWR); if(fd < 0) { printf("Fail to file open\n"); return; } r = read(fd, buf, 32); buf[31] = '\0'; printf("File read %d bytes: %s\n", r, buf);}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?