So I have to connect to a server on a specific port but all I have to identify the server is its name, e.g. "" in a char*. How can I get the ip address to assign to a sockaddr_in?

struct sockaddr_in server;
memset($server, 0, sizeof(server));
server.sin_family = AF_INET;
//server.sin_addr.s_addr = -><-
server.sin_port = ####;

gethostbyname() sounds promising but I can't find a decent example. Any help would be greatly appreciated.