i could get the following code...but cant understand how it works.....can u pls explain it....
code:cpp

Code:
#include<string.h>
#include<conio.h>
#include<stdio.h>
#include<math.h>
union ipadd
 {
 unsigned long int a;
 } e;
void main()
{
char ip[100];
char *p;
int i,n,j,po;
unsigned long int d;
e.a=0;
clrscr();
printf("\nenter the ip");
scanf("%s",ip);
p=strtok(ip,".");
n=strlen(p) ;
d=0;
po=0;
for(i=n-1;i>=0;i--)
 {
 d=d+(*(p+i)-48)*pow(10,po);
 po++;
 }
e.a=d*pow(256,3);
for(j=2;j>=0;j--)
 {
  p=strtok(NULL,".");
  n=strlen(p);
  d=0;
  po=0;
  for(i=n-1;i>=0;i--)
    {
     d=d+(*(p+i)-48)*pow(10,po);
     po++;
    }
  e.a=e.a+d*pow(256,j);
  }
printf("\n the ip add is :%lu",e.a);
getch();
}

Last edited by shabbir; 18Nov2007 at 21:07.. Reason: Code block