how to get ip address of my computer

Posted by asthagoyal on Stack Overflow See other posts from Stack Overflow or by asthagoyal
Published on 2010-03-29T13:14:14Z Indexed on 2010/03/29 13:23 UTC
Read the original article Hit count: 305

Filed under:

hello i want to get ipaddress of my computer in variable ip thru this code but it assign nothing in ip

char comm[100];
int s=0;
char ip[100];
sprintf(comm,"export ip=`/sbin/ifconfig eth0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'`");
s=system(comm); 
printf("\n ip is %s",ip);

© Stack Overflow or respective owner

Related posts about linux