Answers

Question and Answer:

  Home  Search Pattern

⟩ What is the output of this program? #include<stdio.h> #include<fcntl.h> int main() { int fd, count; char ch[10]; fd = open("google.txt",O_RDWR|O_CREAT); write(fd,"linux",5); lseek(fd,2,SEEK_END); write(fd,"san",3); lseek(fd,0,0); count = read(fd,ch,10); printf("%sn",ch); return 0; } a) linux b) linuxsan c) linux san d) none of the mentioned

a) linux

Explanation:

The lseek function allows the file offset to be set beyond the end of the file and if the data is latter written this point, subsequent reads of the data in the gap returns NULL.

Output:

[root@localhost google]# gcc -o san san.c

[root@localhost google]# ./san

linux

[root@localhost google]#

 191 views

More Questions for you: