📄 rd.c
字号:
#include <stdio.h>#include <fcntl.h>#include <sys/types.h>struct stu_r { int id; char name[64]; int chinese; int english; int math;};intmain(){ struct stu_r stu[10]; int i,ret; int fd; fd=open("/tmp/score",O_RDONLY); if (fd==-1) { perror("open()"); exit(1); } ret=read(fd,stu,sizeof(struct stu_r)*10); if (ret<sizeof(struct stu_r)*10) { fprintf(stderr,"Only %d bytes loaded.\n",ret); } else { fprintf(stderr,"Loaded.\n"); } close(fd); for (i=0;i<ret/sizeof(struct stu_r);i++) { printf("Student: Name=%s(%d)\n",stu[i].name,stu[i].id); printf("\tmath=%d\n\n",stu[i].math); } exit(0);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -