What is the output of this program? [code] #include<stdio.h> #include<sys/types.h> #include<sys/socket.h> int main() {

What is the output of this program?
Code:
   #include<stdio.h>
   #include<sys/types.h>
   #include<sys/socket.h>
   int main()
   {
       int fd;
       fd = socket(AF_UNIX,SOCK_STREAM,0);
       printf("%d\n",fd);
       return 0;
   }
A. 0
B. 1
C. 2
D. 3
 
Answer: d
Explanation: The socket() returns the lowest available file descriptor and in this program i.e. 3.
Output:
[root@localhost 123hoidap]# gcc -o san san.c
[root@localhost 123hoidap]# ./san
3
[root@localhost 123hoidap]#
 

Tìm kiếm

Back
Top