get host name, from web address algorithm
gets the hostname, from a web address.
AI
AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
Source Code
#include<iostream>
#include<cstdlib>
#include<cstring>
using namespace std;
void getname(char* host, char* name);
int main()
{
char name[255];
getname("http://www.lostsidedead.com/user/bin/",name);
cout << name << endl;
system("pause");
return (0);
}
void getname(char* host, char* name)
{
int i,num = 0;
int pos = 0;
int off = 0;
int stop = 0;
for(i = 0; i < strlen(host); i++)
{
if(host[i] == '/')
{
num ++;
if(num == 2)
{
pos = i+1;
break;
}
}
}
for(i = pos; i < strlen(host); i++)
{
if(host[i] == '/')
{
stop = i;
break;
}
}
if(stop == 0)
{
stop = strlen(host);
}
for(i = pos; i < stop; i++)
{
name[off] = host[i];
off++;
}
name[off] = 0;
}
Original Comments (3)
Recovered from Wayback Machine