#include "stdafx.h"
#include "stdlib.h"
#include <iostream>
#include <fstream>
using namespace std;
int main(int argc, char* argv[])
{
ifstream file;
file.open("d:\\1.txt",ios::in);//默认HTML文件位置
file.seekg(0,ios::beg);
int begin = file.tellg();
file.seekg(0, ios::end );
int theend = file.tellg();
int length = theend - begin;//得到文件长度
file.seekg(0,ios::beg);
char* temp = new char[length];
file.read(temp,length);
file.close();
string str(temp);
int i = 0;
int first;
string ttt="";
while (i < str.length())
{
if(str[i] == '>')// '>' 和'<' 之间的是有用文本
{
first = i;
while (str[i] != '<'&& i < str.length())
{
i++;
}
if(i == str.length())
{
delete temp;
return 0;
}
else
{
if(first != i)
{
string tt = str.substr(first+1,i-first-1);
cout<<tt.c_str();
}
}
}
else
{
i++;
}
}
}
可以利用stach实现提取 link 等等~~
|