如何判断输入的是域名还是ip?附代码,谢谢。
给socketconnection赋值连接地址,有address和host两项,要求给输入一个字符串后,判断是域名或是ip后,正确赋值给上面两个参数。
我写过一断,但是总不能正常。指教啊。
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char *p=Edit1->Text.c_str();
bool switcher=true;
for(iint i=0,j=Edit1->Text.Length();;i<j;i++)
{
if((p[i]<48||p[i]>57)&&p[i]!='.')
{Memo1->Lines->Add("a character found in the string.it is "+AnsiString(p[i]));
switcher=false;
free (p);}
else
{ Memo1->Lines->Add("number found in this round.it is "+AnsiString(*p++));}
}
}