?? _more.h
字號:
#include<sys/stat.h>#include<sys/types.h>#include<sys/wait.h>#include<unistd.h>#include<stdlib.h>#include<stdio.h>#include<string.h>#include<signal.h>#include<dirent.h>void _more(char *str){ char c[4]; long pos[100]; int i=0,n=0; FILE *file=fopen(str,"r+"); if(file==NULL) { printf("can not open file %s\n",str); return; } char buf[80]; int tag=1; for(i=0;i<23;i++) { if(!fgets(buf,80,file)) { tag=0; break; } else fputs(buf,stdout); } pos[n] = ftell(file); printf("pos[%d] : %d\n",n,pos[n]); n = n+1; printf("%s","input \'b\' to quit:"); while( fgets(c,4,stdin) && tag) { if(c[0] == 'b' || c[0] == 'B') { if(n == 1 || n == 2) { fseek(file,0,SEEK_SET); n=0; } else{ fseek(file,pos[n-3],SEEK_SET); n=n-2; } } for(i=0;i<23;i++) { if(!fgets(buf,80,file)) { tag=0; break;} else { fputs(buf,stdout); } } pos[n] = ftell(file); printf("pos[%d] : %d\n",n,pos[n]); n = n+1; c[0] = 0; printf("%s","input \'b\' to quit:"); }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -