Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   finding ip addr from a c prog (http://www.go4expert.com/forums/finding-ip-addr-c-prog-t1288/)

ismitevijay 28Aug2006 19:12

finding ip addr from a c prog
hi all;
i hav written a code in c for finding ip:



int main()
        struct ifreq ifr;
        char buf[30];
        int fd;
        strcpy(buf,inet_ntoa(((struct sockaddr_in *) &ifr.ifr_addr)->sin_addr));
        printf(" %s",buf);
        return 0;

but i m getting err as :
ip.c: In function ‘main’:
ip.c:15: error: ‘struct ifreq’ has no member named ‘if_name

tell me wat i m missisng

shabbir 28Aug2006 20:44

Re: finding ip addr from a c prog
if_name is not a member of ifreq structure.

The structure contains 128 bytes which has the following members
Code: C

union {
   sockaddr   ifru_addr
   sockaddr   ifru_dstaddr
   sockaddr   ifru_broadaddr
   short   ifru_flags
   int   ifru_metric
   caddr_t   ifru_data

All times are GMT +5.5. The time now is 14:17.