Hi ,
I have to write a low level program in C to simulate the TYPE command in dos.
I got half way through, but i am not able to print the contents of the file. also i tried to incorporate the feature that if the file contents are too big to be printed on one screen. the user is prompted to press any key to continue and the rest is printed.
Code:
#include<stdio.h>
#include<conio.h>
#include<fcntl.h>
#include<string.h>
void main(char *argv[])
{
int inhandle, bytes,x;
char buffer[512],ch;
int i,j;
inhandle = open(argv[1],O_RDONLY|O_BINARY);
while(1)
{
bytes=read(inhandle,buffer,512);
if(bytes>0)
{
j=strlen(buffer);
write(stdout,buffer,bytes);
for(i=0;i<j;i++)
{
x=wherex();
if(x==23)
{
printf(" END OF PAGE : PRESS ENTER ");
getch();
clrscr();
}
else
{
}
}
}
else
break;
}
close (inhandle);
}