By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,134 Members | 1,742 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,134 IT Pros & Developers. It's quick & easy.

which .h or lib should i include before i use "inet_ntoa"

P: 2
I tried to run "inet_ntoa(*((struct in_addr *)h->h_addr))", but it always says 'inet_ntoa' has not been declared.
What head file should i include to make the above code running? The following is the head files I have already included.

#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <netdb.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
whatelse do i need?
I m running the code under linux.
g++
thnx
Jun 29 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
googling "inet_ntoa" suggests

you need these 3 headers

Expand|Select|Wrap|Line Numbers
  1.  #include <sys/socket.h>
  2.  #include <netinet/in.h>
  3.  #include <arpa/inet.h>
you don't have the last one included.
Jun 29 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.