It is in UNIX.

1 answer below »
It is in UNIX.
Answered Same DayJun 10, 2021

Answer To: It is in UNIX.

Pulkit answered on Jun 11 2021
162 Votes
86250/cap-nzw45jdw.jpg
86250/Q1.c
#include         /* for lseek */
#include         /* for printf */
#include
        /* for open */
int main(int ac, char *av[])
{
if ( ac < 2 ) return 0;
int fd = open(av[1],O_RDONLY); /* 1 syscall */
int size = lseek(fd, 0, SEEK_END); /* 2 syscalls */
printf("%d\n", size);
close(fd);            /* 3 syscalls */

return 0;
}
86250/Q2.c
#include
#include
int main()
{
int fd;
char A[44] = ("101 GM\tBuick\t2010\n102 Ford\tLincoln\t2005\n");
fd = open("list1.txt",O_WRONLY | O_CREAT | O_TRUNC, 0755);
write(fd,A,44);
close(fd);
}
86250/Q3.c
#include
#include
//main function
int main()
{
//fileDescriptor is an integer that uniquely identifies an open file of a process
//open function uses the following flag codes:
//O_WRONLY -- opens file for write only
//O_CREAT -- creates the file if it does not exist
//O_TRUNC -- if file exists then file is successfully opened and its length is truncated to 0
//The last parameter is basically the file protection mode indicating rwx permissions
int fileDescriptor = open("list1.txt",O_WRONLY | O_CREAT |...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here