Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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

1 answer below »
Answered Same Day Jan 22, 2021

Solution

Pratik answered on Jan 23 2021
153 Votes
/**
The end command prints the last n (default 5) lines
of a file to the console
Use as ./end filename [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