i need 2 small functions to be written using system calls and I/O

1 answer below »
Answered Same DayJan 22, 2021

Answer To: i need 2 small functions to be written using system calls and I/O

Pratik answered on Jan 23 2021
141 Votes
/**
The end command prints the last n (default 5) lines
of a file to the console
Use as ./end fil
ename [n]
*/
#include
#include
#include
#include
#ifndef BUF_LEN
#define BUF_LEN 10
#endif
void print_usage()
{
    char *msg = "Usage : ./end filename [n] \n Example : ./end Hello.txt 15\nNote : [n] should be more than 10 \n";
    write(STDOUT_FILENO,msg,100);
    exit(1);
}
int main(int argc, char const *argv[])
{
    // Variable declarations
    int FD,openFlags,lines;
    char *endptr;
    mode_t permFlags;
    char buf[BUF_LEN];
    ssize_t len;
    off_t...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here