gethostbyname example that compiles and runs clean on puias6

While playing around with getting host entries to work with ldap, I found that my previous code for using gethostbyname was not running clean on puias6. Here is an updated version

<br />
#include <stdio.h><br />
#include <netdb.h><br />
#include <stdlib.h><br />
#include <sys/socket.h><br />
#include <netinet/in.h><br />
#include <arpa/inet.h></p>
<p>int main(int argc, char **argv) {<br />
	int i;<br />
	struct hostent *hp;<br />
	struct in_addr **addr_list;</p>
<p>	if (argc < 2) {<br />
		printf("Usage: %s hostname\n", argv[0]);<br />
		exit(1);<br />
	}</p>
<p>	hp = gethostbyname(argv[1]);<br />
	if (hp == NULL) {<br />
		printf("gethostbyname(%s) failed\n",argv[1]);<br />
	} else {<br />
		printf("%s has address ", hp->h_name, argv[1],hp->h_addrtype);<br />
		addr_list = (struct in_addr **)hp->h_addr_list;</p>
<p>		for(i = 0; addr_list[i] != NULL; i++) {<br />
			printf("%s ",inet_ntoa(*addr_list[i]));<br />
			}<br />
	printf("\n");<br />
  }<br />
}<br />

compile this with gcc -o gethostbyname gethostbyname.c

About the Author...

Slides from LISA 2019 Linux systems troubleshooting #LISA2019 https://t.co/D4dMKflK6R Tue Oct 29 05:59:30 +0000 2019

https://t.co/AGeihMALAv configuring grub2 with EFI Fri Sep 13 05:20:01 +0000 2019

I published a Thing on @thingiverse! https://t.co/IYpRyEb7Hz #thingalert Tue Jul 23 19:27:57 +0000 2019

Nokogiri install on MacOSX https://t.co/v3An0miW9L Fri Jul 12 15:06:49 +0000 2019

HTML email with plain mailer plugin on Jenkins https://t.co/Z6FSDMDjy8 Thu Jul 11 21:07:25 +0000 2019