i m writing a program which finds the i.p address of the machine.
but it just prints out the first three character of the ifconfig output
but i want to just print my i.p address lik 10.0.0.222 which is in second line after inet addr:
code :
#include<iostream>
#include<cstdlib>
using nammespace std;
int main ()
{
FILE * fp
fp =popen ("ifconfig eth0","r")
char mystring [100];
if (fb==NULL)perror("error");
else {
if (fgets(mystring , 100, fp)) !=NULL)
puts (mystring);
pclose (fp)
}
return 0;
}