I’m trying to create socket, and I should describe some structures:
(struct in_addr) addr;
addr.s_addr = INADDR_ANY;
also I have included headers
#include <sys/socket.h>
#include <sys/types.h>
But gcc says that there is an error:
error: ‘addr’ undeclared (first use in this function)
What am I doing wrong?
To declare a new
in_addrstruct, you need to remove those parentheses:What you have at the moment is a cast, which means (approx.) “assuming
addris already a declared variable of some other type, try to convert it to astruct in_addr“.