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; fd = open("san.c",O_RDONLY); count = write(fd,"Linux",5); if(count != 5) perror("write"); return 0; } a) it will write the string "Linux" in the beginning of source file "san.c" b) it will write the string "Linux" in the end of the source file "san.c" c) segmentation fault d) none of the mentioned

d) none of the mentioned

Explanation:

This program will write nothing in the source file "san.c" because we are opening the file in read only mode.

Output:

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

[root@localhost google]# ./san

write: Bad file descriptor

[root@localhost google]#

 140 views

More Questions for you: