📄 file_access.c
字号:
#include <stdio.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <fcntl.h>#include <unistd.h>int main(void){ int file = 0, exit_wait; char buffer[10] = {0}; file = open("test.txt", O_RDONLY); printf("The file descriptor returned is %d\n", file); if (file == -1) { printf("The file opening failed.\n"); exit(0); } read(file, (void*)buffer, 9); buffer[9] = '\0'; printf("The data read from the file is %s\n", buffer); scanf("%d", &exit_wait);/*Make the process blocked here so that the kernel data structure can be inspected.*/ close (file); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -