📄 demo.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <unistd.h>#include <fcntl.h>int main(){ int fd,i,nwrite,nread; char *buf="HELLO WORLD!"; char read_buf[1024]={0}; // user space buffer fd=open("/dev/szx",O_RDWR); if(fd<=0) { perror("ERROR in opening this file, please CHECK the device!"); exit(1); } else printf("File open SUCCESSFUL!\n"); nwrite=write(fd,buf,strlen(buf)); // write data to myfs if(nwrite<0) { perror("ERROR in writing this file!"); exit(1); } printf("PRESS ANY KEY TO CONTINUE..."); getchar(); nread=read(fd,read_buf,1024); //read data from myfs if(nread<0) { perror("ERROR in reading this file!"); exit(1); } else printf("The written string is: %s\n",read_buf); close(fd); exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -