#include <stdio.h>
#include <iostream>
using namespace std;
int main(){
char pHost[100];
char pResource[2000];
const string url ="http://lishi.tianqi.com/nanjing/201111.html";//"http://www.baidu.com";
const char * pos = strstr(url.c_str(), "http://");
pos += strlen("http://");
if (strstr(pos, "/") == 0)
printf("wei 0 wei 0 有//还为0");
sscanf(pos, "%[^/]%s", pHost, pResource);
puts(pHost);
puts(pResource);
return 0;
}
/*
//端口
const char *s = "http://www.baidu.com:1900";
char protocol[32] = { 0 };
char host[128] = { 0 };
char port[8] = { 0 };
sscanf(s,"%[^:]://%[^:]:%[1-9]",protocol,host,port);
printf("protocol: %s\n",protocol);
printf("host: %s\n",host);
printf("port: %s\n",port);
*/
#include <iostream>
using namespace std;
int main(){
char pHost[100];
char pResource[2000];
const string url ="http://lishi.tianqi.com/nanjing/201111.html";//"http://www.baidu.com";
const char * pos = strstr(url.c_str(), "http://");
pos += strlen("http://");
if (strstr(pos, "/") == 0)
printf("wei 0 wei 0 有//还为0");
sscanf(pos, "%[^/]%s", pHost, pResource);
puts(pHost);
puts(pResource);
return 0;
}
/*
//端口
const char *s = "http://www.baidu.com:1900";
char protocol[32] = { 0 };
char host[128] = { 0 };
char port[8] = { 0 };
sscanf(s,"%[^:]://%[^:]:%[1-9]",protocol,host,port);
printf("protocol: %s\n",protocol);
printf("host: %s\n",host);
printf("port: %s\n",port);
*/