Linux Search Pattern Question: Download Questions PDF
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
Answer:
a) it will print nothing
Explanation:
none.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
#include
#include
int main()
{
int fd, count;
char ch;
fd = open("san.c",O_RDONLY);
do{
count = read(fd,&ch,1);
printf("%c",ch);
}while(count);
}
[root@localhost google]#
Explanation:
none.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
#include
#include
int main()
{
int fd, count;
char ch;
fd = open("san.c",O_RDONLY);
do{
count = read(fd,&ch,1);
printf("%c",ch);
}while(count);
}
[root@localhost google]#
Download Search Pattern Interview Questions And Answers
PDF