Translate

Monday, October 8, 2012

ME NETWORKS LAB-->DOMAIN NAME SERVER


DOMAIN NAME SERVER

#include<stdio.h>

#include<conio.h>

#include<string.h>

void main()

{

char domain[20];

int i,j,n,pos[10],no;

clrscr();

printf("\n Enter the domain name:");

scanf("%s",domain);

n=strlen(domain);

no=0;

pos[no]=0;

for(i=0;i<n;i++)

{

if(domain[i]=='.')

{

no++;

pos[no]=i;

}

}

no++;

pos[no]=n;

printf("The subdomains are:");

for(i=0;i<n;i++)

{

if(domain[i]!='.')

printf("%c",domain[i]);

else

printf("\n");

}

printf("\n");

for(i=no;i>=1;i--)

{

printf("connecting subdomain");

for(j=pos[i-1];j<=pos[i];j++)

{

if(domain[j]=='.')

{

continue;

}

printf("%c",domain[j]);

}

 

printf("\n Redirecting\7\7");

}

printf("obtaining IP address id %d%d%d%d",domain[4],domain[5],domain[7],domain[8]);

getch();

}

 

 

 

OUTPUT:

 

 Enter the domain name: www.google.com

The subdomains are:

 www

google

com

connecting subdomain:   com

 Redirectingconnecting subdomain:  google

 Redirectingconnecting subdomain:  www

 Redirectingobtaining IP address :  103.111.103.108

 

No comments:

Post a Comment