- 论坛徽章:
- 0
|
#include <stdio.h>
#define LEN 512
#define PAGESIZE 24
void do_more(FILE *);
int see_more();
int main(int argc, char **argv)
{
FILE *fp;
if(argc <= 1)
printf("No Filename has been indicated\n");
while(--argc >= 1)
{
fp = fopen(*++argv, "r");
if(fp != NULL)
{
do_more(fp);
fclose(fp);
}
}
return 0;
}
void do_more(FILE *fp)
{
int num = 0;
char line[LEN];
int reply;
while(fgets(line,LEN,fp))
{
if(num == PAGESIZE)
{
reply = see_more();
if(reply == 0)
break;
num -= reply;
}
fputs(line, stdout);
num++;
}
}
int see_more()
{
char c;
if((c=getchar()) != EOF)
{
if(c == 'q')
return 0;
if(c == ' ')
return PAGESIZE;
if(c == '\n')
return 1;
}
}
为什么敲空格没反应。 |
|