匹配字符串,该如何处理
匹配字符串
void main()
{
char szbuf[1024] = { "asdfshttp://fsadfsadfasd.jpgf "};// 自己去把网页读到这个缓冲里
char* pstart = szbuf;
FILE* pf = fopen( "c:\\out.txt ", "wb ");
while(true)
{
char* p = strstr(pstart, "http:// ");
if(!p)
break;
char* pend = strstr(p, ".jpg ");
if(!pend)
break;
fwrite(p, 1, pend - p + strlen( ".jpg "), pf);
fwrite( "\r\n ", 1, 2, pf);
pstart = p + strlen( "http:// ");
}
fclose(pf);
}
那么如何把网页读到这个缓存中????
还有能详细讲解下这代码的作用吗?
是从这贴子来的:
http://community.csdn.net/Expert/topic/5294/5294726.xml?temp=7.503909E-02
------解决方案--------------------
稍作改动即可,例如:
void main()
{
char szbuf[1024] = {0};// 自己去把网页读到这个缓冲里
// 假设网页你保存到硬盘中了,为 c:\index.htm
FILE* pfHtml = fopen( "c:\\index.htm ", "rb ");
fread(szbuf, 1, 1024, pfHtml);
fclose(pfHtml);
char* pstart = szbuf;
FILE* pf = fopen( "c:\\out.txt ", "wb ");
..................下同
------解决方案--------------------
就是下载页面然后读取信息 ~~~~
PS:
楼主的这个 主题:匹配字符串 ??
汗 ~
void main()
{
char szbuf[1024] = { "asdfshttp://fsadfsadfasd.jpgf "};// 自己去把网页读到这个缓冲里
char* pstart = szbuf;
FILE* pf = fopen( "c:\\out.txt ", "wb ");
while(true)
{
char* p = strstr(pstart, "http:// ");
if(!p)
break;
char* pend = strstr(p, ".jpg ");
if(!pend)
break;
fwrite(p, 1, pend - p + strlen( ".jpg "), pf);
fwrite( "\r\n ", 1, 2, pf);
pstart = p + strlen( "http:// ");
}
fclose(pf);
}
那么如何把网页读到这个缓存中????
还有能详细讲解下这代码的作用吗?
是从这贴子来的:
http://community.csdn.net/Expert/topic/5294/5294726.xml?temp=7.503909E-02
------解决方案--------------------
稍作改动即可,例如:
void main()
{
char szbuf[1024] = {0};// 自己去把网页读到这个缓冲里
// 假设网页你保存到硬盘中了,为 c:\index.htm
FILE* pfHtml = fopen( "c:\\index.htm ", "rb ");
fread(szbuf, 1, 1024, pfHtml);
fclose(pfHtml);
char* pstart = szbuf;
FILE* pf = fopen( "c:\\out.txt ", "wb ");
..................下同
------解决方案--------------------
就是下载页面然后读取信息 ~~~~
PS:
楼主的这个 主题:匹配字符串 ??
汗 ~