Linux Search Pattern Question:
Download Questions PDF

In the output of this program, the string "/* Linux */" will be added at the ____ of the source file.

#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>

int main()
{
int fd;
fd = open("san.c",O_RDWR|O_APPEND);
write(fd,"/* Linux */",11);
return 0;
}
a) end
b) beginning
c) second line
d) third line

Search Pattern Interview Question
Search Pattern Interview Question

Answer:

a) end
Explanation:
The write system call writes at the end of the file because the file is opened with O_APPEND flag.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
[root@localhost google]# vim san.c
[root@localhost google]#

Download Search Pattern Interview Questions And Answers PDF

Previous QuestionNext Question
Output of this program?

#include<stdio.h>
#include<fcntl.h>

int main()
{
pid_t fd;
char ch;
int count;
fd = open("san.c",O_RDONLY);
do{
count = read(fd,&ch,1);
printf("%c",ch);
}while(count);
return 0;
}
a) it will print nothing
b) it will print the source code of the source file "san.c"
c) segmentation fault
d) none of the mentioned
Assuming the files fileA, fileB, fileAB, fileBC and fileABC, exist in a directory, which files match with the pattern file[ABC]?
a) fileA, fileB and fileABC
b) fileABC
c) fileA and fileB
d) fileAB, fileBC and fileABC