fclose() 提示No source available for ""

coolmurder 2009-03-25 03:11:34
DEBUG模式下代码执行到第二个fclose(f);的时候就提示No source available for ""
大家帮忙看下什么原因

#include <stdio.h>

int main()
{
int len;
char * buff;

FILE * f;

f = fopen("/home/config.xml", "rt");

if (!f)
{
fclose(f);

return 1;
}

fseek(f, 0L, SEEK_END);
len = ftell(f);
buff = new char(len);
fseek(f,0L, SEEK_SET);

fread(buff, len, 1, f);

printf("%s", buff);

fclose(f);

delete[] buff;

return 0;
}

...全文
239 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bao001001 2009-03-25
  • 打赏
  • 举报
回复
[Quote=引用楼主 coolmurder 的帖子:]
if (!f)
{
fclose(f);

return 1;
}
[/Quote]

fclose(f) has problem because f is null pointer. please check error status after fopen() call.
downmooner 2009-03-25
  • 打赏
  • 举报
回复
 if (f==NULL) 
{

return 1;
}

buff = new char[len];

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧