I have a piece of code which looks like
#include <stdio.h>
#include <netdb.h>
#include <arpa/inet.h>
int main(int argc, char *argv[])
{
struct hostent *server;
server = gethostbyname(argv[1]);
struct in_addr * address=(in_addr * )server->h_addr;
fprintf(stderr,"[%d] [%s] server [%s] \n",__LINE__,__func__,inet_ntoa(*address));
}
When i use g++ compiler it gets compiled but the same gives the following error with gcc compiler
myclient.c: In function ‘main’:
myclient.c:10:31: error: ‘in_addr’ undeclared (first use in this function)
myclient.c:10:31: note: each undeclared identifier is reported only once for each function it appears in
myclient.c:10:41: error: expected expression before ‘)’ token
Am I missing something here?