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

Last edited by shabbir; 28Aug2006 at 20:42.. Reason: Code formating.