Linux OS Management Question:
Download Questions PDF

Code snippets

str1="45678n"
str2="123n"
f1 = fopen(file1,RDWR,RWX)
f2 = dup(f1)
write(f1,str1,len_str1)
write(f2,str2,len_str2)

o/p:

a) 12378
b) 123(newline)8(newline)
c) 123(newline)78(newline)
d) 45678(newline)123(newline)

Answer:

d) 45678(newline)123(newline)

Download Linux Operating System Management Interview Questions And Answers PDF

Previous QuestionNext Question
Code snippet (file1 size is 2024)

f1 = fopen (file1, RDWR, RWX)
lseek(f1,1024,SEEK_SET)
write(f1,buf,10)
What is offset now.

a) 1024
b) 1034
c) 2034
d) 2054
For the below mentioned code:

int main() {
int fd;
fd = open("logfile", O_CREAT|O_RDWR, 0600);
lseek(fd, 5, SEEK_CUR);
write(fd, "Hello", 5);
return 0;
}

What is the logfile size now if it's initially was 1024 bytes?

a) 5
b) 1024
c) 1029
d) 1034