这是我的代码:
#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;
}
Run Code Online (Sandbox Code Playgroud)
当我编译它时,它显示:
a.c:2: fatal error: socket.h: No such file or directory
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
那么如何包含它/哪里可以下载呢?
它应该是:
#include <sys/socket.h>
Run Code Online (Sandbox Code Playgroud)
路径是相对于/ usr/include路径给出的.所以例如socket.h文件在/usr/include/sys/socket.h下.如果您不知道,可以搜索它:
find /usr/include/ -name SEARCHED_HEADER.h
Run Code Online (Sandbox Code Playgroud)