Results 1 to 2 of 2
hi , if any body have idea that how to get ip address and hardwared address of network card by using c program then please help me . I have ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 08-30-2006 #1Just Joined!
- Join Date
- Aug 2006
- Posts
- 48
How to get IP of pc using c program
hi , if any body have idea that how to get ip address and hardwared address of network card by using c program then please help me . I have writtne source below i don't have much experience of C programming on linux.
#include <ifaddrs.h>
#include <stdio.h>
int main()
{
struct ifaddrs *id;
int val;
val = getifaddrs(&id);
printf("Network Interface Name :- %s\n",id->ifa_name);
printf("Network Address of %s :- %d\n",id->ifa_name,id->ifa_addr);
printf("Network Data :- %d \n",id->ifa_data);
//printf("%s\n",(id->ifa_next)->ifa_name);
//printf("%d \n",(id->ifa_next)->ifa_addr);
printf("Socket Data : -%c\n",id->ifa_addr->sa_data);
return 0;
}
out put:
Network Interface Name :- lo
Network Address of lo :- 165750228
Network Data :- 165751520
- 08-30-2006 #2Linux Engineer
- Join Date
- Oct 2004
- Location
- Vancouver
- Posts
- 1,366
is this homework...
naughty boy
http://www.linuxforums.org/forum/lin...ums-rules.html


Reply With Quote
