Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Nov 2001 08:15:19 -0800 (PST)
From:      Fabio Miranda <fmirand@yahoo.com>
To:        freebsd-chat@FreeBSD.org
Subject:   struct hostent
Message-ID:  <20011102161519.40762.qmail@web11504.mail.yahoo.com>

next in thread | raw e-mail | index | archive | help
Hi, i am coding a small c program in order to learn
network programming:
main(int argc, char *argv[]){
struct hostent *host;
....
if((host=gethostbyname(argv[1])=NULL)){
        perror("gethostbyname");
        exit(-1);}
/* now, i want to print out all the hostent struct
information */
printf("struct hostent{\n");
printf("char *h_name: %s", host->h_name);
printf("char **h_aliases:%s\n", host->h_length);
printf("int h_addrtype: %d\n", host->h_addrtype);
printf("int h_length:   %d\n", host->h_length);
printf("char **h_addr_list:  %d\n",
host->h_addr_list);
}
}
This program core dumped, it may crash because i am
trying to print an char array (h_addr_list, right?), I
want to know how can i print all the information store
in a struct hostent?, especiality the ip address.

thanks


__________________________________________________
Do You Yahoo!?
Find a job, post your resume.
http://careers.yahoo.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011102161519.40762.qmail>