📄 urls.txt
字号:
#include <iostream.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
char protocol[10],host[500],port[15],path[1000];
char s[2000],c;
long n,number;
int i,j,k=1;
cin>>n;
while(n--)
{
cin>>s;
i=0;
while(s[i]!=':')i++;
s[i]='\0';
strcpy(protocol,s);
strcpy(port,"<default>");
strcpy(path,"<default>");
i=i+3;
j=i;
while(s[i]!=':'&&s[i]!='/'&&s[i]!='\0')i++;
c=s[i];
s[i]='\0';
strcpy(host,s+j);
if(c==':')
{
number=atol(s+i+1);
sprintf(port,"%ld",number);
i++;
while(s[i]!='/'&&s[i]!='\0')i++;
c=s[i];
}
if(c=='/')
{
strcpy(path,s+i+1);
}
cout<<"URL #"<<k<<endl;
cout<<"Protocol = "<<protocol<<endl;
cout<<"Host = "<<host<<endl;
cout<<"Port = "<<port<<endl;
cout<<"Path = "<<path<<endl;
cout<<endl;
k++;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -