开发者

How to include socket.h in my c file in Ubuntu

开发者 https://www.devze.com 2023-03-04 04:20 出处:网络
This is my a.c code : #include <stdio.h> #include <socket.h> int main(void) { int count[4] = {[2] = 3}, i;

This is my a.c code :

#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;
}

When I comp开发者_C百科ile it, it shows:

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

So how do I include it / where can download it?


It should be:

#include <sys/socket.h>

Paths are given relatively to the /usr/include path. So e.g. the socket.h file is under /usr/include/sys/socket.h. You can search for it if you don't know:

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

精彩评论

暂无评论...
验证码 换一张
取 消