mathematics
asked on
How can we get the ip address like ifconfig using C program?
How can we get the ip address like ifconfig using C program?
The question is not the same as what I asked.
The Ip I got was not same as the ifconfig.
I beleive that using ifconfig can get the true ip address
and can ping the IP.
So gethostent(),gethostbyname (), maybe retrieve the ip
address from /etc/hosts,....
Can you help me to write a code like ifconfig
which is not use gethostent with reading /etc/hosts,
(Because /etc/hosts is wrong in my computer.)
Because I use rc.inet1 to set the IP of mycomputer,
These files /etc/hosts , /etc/hostname was not corrected.
That is to say,for example ,
the ip /etc/hosts is 192.168.0.1,
but in the rc.inet1 192.168.0.3,
when using ifconfig , I find the eth0 is 192.168.0.3.
I used Slakware 7.0 distribution.
The question is not the same as what I asked.
The Ip I got was not same as the ifconfig.
I beleive that using ifconfig can get the true ip address
and can ping the IP.
So gethostent(),gethostbyname
address from /etc/hosts,....
Can you help me to write a code like ifconfig
which is not use gethostent with reading /etc/hosts,
(Because /etc/hosts is wrong in my computer.)
Because I use rc.inet1 to set the IP of mycomputer,
These files /etc/hosts , /etc/hostname was not corrected.
That is to say,for example ,
the ip /etc/hosts is 192.168.0.1,
but in the rc.inet1 192.168.0.3,
when using ifconfig , I find the eth0 is 192.168.0.3.
I used Slakware 7.0 distribution.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:
Split: bryanh {http:#7151625} & pianopan {http:#7213250}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jmcg
EE Cleanup Volunteer
I will leave the following recommendation for this question in the Cleanup topic area:
Split: bryanh {http:#7151625} & pianopan {http:#7213250}
Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
jmcg
EE Cleanup Volunteer
some bad way & quick way
system ("ifconfig > /tmp/temp_file")
open the file
then strstr (buffer,"inet addr)
read the next token.