如何包括在Ubuntu

问题描述:

我的C文件socket.h中这是我的AC代码:如何包括在Ubuntu

#include <stdio.h> 
#include <socket.h> 


int main(void) 
{ 
    int count[4] = {[2] = 3 }, i; 

    for (i = 0; i < 4; i++) 
     printf("count[%d]=%d\n", i, count[i]); 
    return 0; 
} 

当我编译它,它表明:

a.c:2: fatal error: socket.h: No such file or directory 
compilation terminated. 

那么,如何包括它/哪里可以下载?

+2

尝试'中'。 – thelaws 2011-05-11 01:39:50

它应该是:

#include <sys/socket.h> 

路径被给予相对到/ usr /包括路径。所以例如socket.h文件位于/usr/include/sys/socket.h下。您可以搜索它,如果你不知道:

find /usr/include/ -name SEARCHED_HEADER.h 
+0

有什么办法可以使它相对'/ usr/include/sys'? – Pacerier 2017-03-03 23:00:35

#include <sys/socket.h> 

下次试试google。

+3

甚至'男子3 socket' :) – sarnold 2011-05-10 06:14:15

+0

或谷歌人插座 – 2011-05-10 06:48:05