hi guy i started learning c recently, and im trying to do exercises from the book the bad thing is they are not showing the solutions.
what i need to do is simply modify the program below so that instead of reading single characters at a time, it reads in blocks of text at a single go, and then displays the block on screen.
im not very sure how to make it work...:/
// read the file from comand lien and displys it
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
main(int argc, char *argv[])
{
int fd ,numseats, i=0;
fd = open(argv[1],O_RDWR);
if(fd <0)
{
printf("file s% not found",argv[1]);
exit(1);
}
while(read(fd, &numseats, sizeof(int)) > 0)
printf("flight%4d: %4d seats available\n",
i++, numseats);
/* finished */
exit(0);
}
also it asks me to let the user choose where the output could be sent to whether screen or specified file.
i hope you could help me with this
thanks a lot guys in advance