What is the output of this program?
#include<stdio.h>
#include<fcntl.h>
int main()
{
pid_t fd;
char ch;
int count;
fd = open("demo.c",O_RDONLY);
do{
count = read(fd,&ch,1);
printf("%c",ch);
}while(count);
return 0;
}
#include<stdio.h>
#include<fcntl.h>
int main()
{
pid_t fd;
char ch;
int count;
fd = open("demo.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 "demo.c"
C. segmentation fault
D. none of the mentioned
Answer: Option B

Join The Discussion