hi all; i hav written a code in c for finding ip: Code: #include<stdlib.h> #include<stdio.h> #include<string.h> #include<sys/ioctl.h> #include<sys/socket.h> #include<linux/if.h> #include<arpa/inet.h> int main() { struct ifreq ifr; char buf[30]; int fd; fd=socket(AF_INET,SOCK_DGRAM,0); strcpy(&ifr.if_name,"eth0"); ioctl(fd,SIOCGIFADDR,&ifr); 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
if_name is not a member of ifreq structure. The structure contains 128 bytes which has the following members Code: union { sockaddr ifru_addr sockaddr ifru_dstaddr sockaddr ifru_broadaddr short ifru_flags int ifru_metric caddr_t ifru_data }