+ -
当前位置:首页 → 问答吧 → CHttpFile问题

CHttpFile问题

时间:2011-12-18

来源:互联网

C/C++ code
CInternetSession sess(_TEXT(""));
CHttpFile* file = (CHttpFile*)sess.OpenURL(_TEXT("http://www.baidu.com"));
string strHtml;
char sRecived[100];
    
while(file->ReadString((LPTSTR)sRecived,100) != NULL)/// 这里有错,把100改成50就没错了。。
{
      strHtml += sRecived;
}
cout << strHtml << endl;
file->Close();
cin.get();


上面这段代码总有错,错误提示为:
CPP.exe 中的 0x6e65633a 处有未经处理的异常: 0xC0000005: 读取位置 0x6e65633a 时发生访问冲突

按照注释里面写的,把100改成50则没有错了,这是怎么回事。。

作者: ereere235   发布时间: 2011-12-18

CInternetFile::ReadString
Call this member function to read a stream of characters until it finds a newline character. The function places the resulting line into the memory referenced by the pstr parameter. It stops reading characters when it reaches the maximum number of characters, specified by nMax. The buffer always receives a terminating null character.
改成:file->ReadString((LPTSTR)sRecived,99)

作者: agoago_2009   发布时间: 2011-12-18

引用 1 楼 agoago_2009 的回复:

CInternetFile::ReadString
Call this member function to read a stream of characters until it finds a newline character. The function places the resulting line into the memory referenced by the pstr p……

改成99也还是有那个错误。。

作者: ereere235   发布时间: 2011-12-18

热门下载

更多