64,682
社区成员
发帖
与我相关
我的任务
分享
char *Readfile(char *filename)
{
char *read_buf = NULL;
if (!filename)
return NULL;
//ifstream fins(filename, ifstream::in);
ifstream fins;//("G:\91mq\tools\UpdateHall\UpdateHall\UpdateHall\ktv1.htm", ifstream::in);
fins.open("G:\91mq\tools\UpdateHall\UpdateHall\UpdateHall\ktv1.htm");
if (!fins)//.good()) //此处总是返回失败,这是为什么啊?不管什么方式,读什么文件,有时成功、有时失败啊!
{
fins.close();
return NULL;
}
fins.seekg(0, ios::end);
int length = fins.tellg();
fins.seekg(0, ios::beg);
read_buf = new char[length + 1];
if (read_buf)
fins.read (read_buf, length);
*(read_buf + length + 1) = '\0';
fins.close();
return read_buf;
}
fins.open("G:\\91mq\\tools\\UpdateHall\\UpdateHall\\UpdateHall\\ktv1.htm");