Implementation Of PG Command


Implementation Of PG Command

#include<stdio.h>
main(int argc,char *argv[])
{
int fd,i,j=0,n=0;
char a,b[100];
if(argc<1)
{
6printf("Argument is missing");
}
fd=open(argv[1],0);
if(fd==-1)
{
printf("File does not exist");
}
i=read(fd,&a,1);
while(i>0)
{
b[j]=a;
if(a=='\n')
{
b[j]='\0';
n++;
if(n%4==0)
{
printf("Press any key to continue");
getchar();
}
printf("%s\n",b);
j=0;
}
else
j++;
i=read(fd,&a,1);
}
}

Output

-bash-3.2$ cc pag.c
-bash-3.2$ ./a.out pag.c
#include<stdio.h>
main(int argc,char *argv[])
{
Press any key to continue
int fd,i,j=0,n=0;
char a,b[100];
if(argc<1)
{
Press any key to continue