这是我的a.c代码:
#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.
那我该如何包含它/哪里可以下载呢?
答案 0 :(得分:7)
应该是:
#include <sys/socket.h>
路径是相对于/ usr / include路径给出的。所以例如socket.h文件位于/usr/include/sys/socket.h下。如果您不知道,可以搜索它:
find /usr/include/ -name SEARCHED_HEADER.h
答案 1 :(得分:3)
#include <sys/socket.h>
下次尝试谷歌。