What is the output of this program? [code] #include<stdio.h> #include<stdlib.h> #include<fcntl.h> int main() { int

What is the output of this program?
Code:
   #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("%d\n",count);
       return 0;
   }
A. 5
B. 10
C. 0
D. -1
 
Answer: a
Explanation: The “read” system call returns the number of bytes successfully read.
Output:
[root@localhost 123hoidap]# gcc -o san san.c
[root@localhost 123hoidap]# ./san
5
[root@localhost 123hoidap]#
 

Tìm kiếm

Back
Top