Linux Search Pattern Question:
Tell us what is the output of this program?
#include<stdio.h>
#include<stdlib.h>
#include<fcntl.h>
int main()
{
int fd, count;
char ch, *buff;
buff = (char *)malloc(sizeof(char)*10);
fd = open("san.c",O_RDONLY);
count = read(fd,buff,5);
printf("%dn",count);
return 0;
}
a) 5
b) 10
c) 0
d) -1

Answer:
a) 5
Explanation:
The "read" system call returns the number of bytes successfully read.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
5
[root@localhost google]#
Explanation:
The "read" system call returns the number of bytes successfully read.
Output:
[root@localhost google]# gcc -o san san.c
[root@localhost google]# ./san
5
[root@localhost google]#