-3
我在这里构建webcrawler。我开始调试时发生此错误,并将我发送到memcpy.asm
或xstring
或dbgdel.cpp
文件,每次显示这些文件的不同行。C++访问冲突写入位置0x000A000B
我想知道代码是否错了。我开始想我正在访问我不应该使用的内存块。这是一些代码。我希望你能帮忙。
这个想法是遍历httpContent
并从<a>
标签获得所有的URL。我在开始寻找href="
,然后寻找下一个"
。我在尝试输入temp
之间的内容,然后将temp
的内容传递给一个字符串数组。
struct Url
{
string host;
string path;
};
int main(){
struct Url website;
string href[100];
website.host = "crawlertest.cs.tu-varna.bg";
website.path = "";
string httpContent = downloadHTTP(website);
for(unsigned int i = 0; i <= httpContent.length()-7; i++){
char c = httpContent[i];
if(c == 'h'){
c = httpContent[i+1];
if(c == 'r'){
c = httpContent[i+2];
if(c == 'e'){
c = httpContent[i+3];
if(c == 'f'){
c = httpContent[i+4];
if(c == '='){
c = httpContent[i+5];
if(c == '\"'){
i+=6;
c = httpContent[i];
string temp = "";
while(c!='\"'){
i++;
c = httpContent[i];
temp+= c;
}
href[i] = temp;
temp = "";
cout<<href[i]<<endl;
}}}}}}
}
system("pause");
return 0;
}
UPDATE
我编辑了=
,现在==
我也停止迭代7位早先所以“如果公司不应该是问题。
虽然我收到相同的错误。
你即使那些严重'如果公司使用'='的'而不是'== –
您的所有'INT I = 0;我<= httpContent.length()'好吧,这可能不是很好,因为'httpContent [i]'将在最后一次迭代中超出范围....'c = httpContent [i + 5];',嗯 – NathanOliver
if's – AndyG