Question: Write the program in C. Create your own fgets() and fputs() using only Unix system calls such as open, read, write, close etc, so no
Write the program in C. Create your own fgets() and fputs() using only Unix system calls such as open, read, write, close etc, so no standard input/outputs functions are allowed.
Using only the Unix input/output system calls(do not use any standard input/output functions), define two C functions, called myFgets() and myFputs() with the following requirements: int myFgets(char *s, int size, int stream): reads in at most one less than size characters from stream (file descriptor is stream) and stores them into the buffer pointed to by s. Reading stops after an EOF or a newline (i.e., reading should be done one byte at a time). If a newline is read, it is stored into the buffer. A terminating null byte is stored after the last character in the buffer. This function returns the number of characters read or, 0 for end of file or -1 in case of error. int my Fputs(const char *s, int *stream), writes the string s to stream, without its terminating null byte. This function returns the number of characters written or -1 in case of error. Then, define your main function to perform a copy task using your defined functions, myFgets() and myF- puts(). Your C program takes two arguments, input file and destination file.
Step by Step Solution
3.43 Rating (156 Votes )
There are 3 Steps involved in it
To Define two C functions myFgets and myFputs using Unix inputoutput system calls There is a problem ... View full answer
Get step-by-step solutions from verified subject matter experts
