Torbj�rn S. Kristoffersen wrote:

> I've made this program that converts hostnames from a file (hosts.txt)
> to ip addresses which are stored in a file called ipaddresses.txt.
> 
> But the problem is that this error occurs:
> gethostbyname: Unknown host
> 
> - even if it is a perfectly valid host.
> 
> I've set everything correct in /etc/resolv.conf etc.
> 
> Here's the source code:

>        if(!fgets(line, sizeof(line), rfile))
>           break;
> 
>           if((h=gethostbyname(line)) == NULL)

fgets() stores the trailing newline in the buffer. I doubt that many
hostnames end with a newline.

-- 
Glynn Clements <[EMAIL PROTECTED]>

Reply via email to