Prog#226: page command


#1
/*
page command
Program#226
*/
#include<stdio.h>
main(int argc,char *argv[])
{
int p,i,j,n;
char a[800];
if(argc!=2)
{
printf("error: no.of arg");
return 0;
}
p=open(argv[1], 0);
if(p==-1)
{
printf("file open error");
return 0;
}
for(j=0,n=0;(i=read(p,&a[j],1))>0;j++)
{
if(a[j]=='\n')
{
a[j]='\0';
n++;
printf("%d %s", n,a);
if(n%24==0)
getchar();
j=-1;
}
}
close(p);
}