您的位置:程序门 -> .net技术 -> vc.net



使用 chttpfile 读文件出错,请高手看看吧,谢谢


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


使用 chttpfile 读文件出错,请高手看看吧,谢谢
发表于:2008-01-16 16:23:42 楼主
我想通过chttpfile   来获取网页内容。函数代码比较简单,但是一直存在问题,请帮忙看看吧,谢谢了。
相关源代码如下:
int   cautobuxview::autoclixwebsite(cstring   strurl)  
{
cinternetsession   mysession(null,0);
chttpfile*   myhttpfile=null;
cstring   stroneline;
cstring   strwebcontent;
int   i;

myhttpfile=(chttpfile*)mysession.openurl(strurl);
i=0;
strwebcontent.empty();
stroneline.empty();
while   (myhttpfile-> readstring(stroneline))
{
i++;
stroneline.makelower();
trace("%d:%s\n",i,stroneline);
}
myhttpfile-> close();
delete   []myhttpfile;
return   0;
}

运行的时间弹出一个assert对话框,选择retry之后就跳到了mfc\src\dumpout.cpp   文件,并且指向
#ifdef   _debug   //   all   afxtrace   output   is   controlled   by   afxtraceenabled
if   (!afxtraceenabled)
return;
#endif

va_list   args;
va_start(args,   lpszformat);

int   nbuf;
tchar   szbuffer[512];

nbuf   =   _vsntprintf(szbuffer,   _countof(szbuffer),   lpszformat,   args);

//   was   there   an   error?   was   the   expanded   string   too   long?
assert(nbuf   > =   0);// <--------------------------------------光标指向这一句

if   ((afxtraceflags   &   tracemultiapp)   &&   (afxgetapp()   !=   null))
afxdump   < <   afxgetapp()-> m_pszexename   < <   ":   ";
afxdump   < <   szbuffer;

va_end(args);
}
#endif   //_debug


请高手看看是什么原因?如何解决?谢谢了。
发表于:2008-01-16 16:47:431楼 得分:0
什么问题
发表于:2008-01-16 16:55:582楼 得分:0
就是上面的第一个函数中

while       (myhttpfile->   readstring(stroneline))  
或者
stroneline.makelower();  
会导致弹出一个assert对话框,如何不让对话框出现?这个对话框是由上面的doumpout文件中的那个assert引起的
我不知道该如何消除?
谢谢
发表于:2008-01-17 10:30:523楼 得分:0
实际构造的字符串数据超过了512的缓冲区大小
发表于:2008-01-17 11:27:484楼 得分:0
up
发表于:2008-01-18 13:06:475楼 得分:0
那该怎么修改呢?
谢谢
发表于:2008-01-18 13:12:416楼 得分:0
把缓冲区设计得足够大,或者动态申请内存


快速检索

最新资讯
热门点击