[提问]Borland C++ Builder中的文件操作解决方法

[提问]Borland C++ Builder中的文件操作 - C++ Builder / Windows SDK/API
我在Borland C++ Builder 5 中的程序中有这样几段关键代码:
  struct FrequentItem
  {  
  unsigned char szName[16];
  unsigned int nCount;
  };
  FrequentItem buf;
  vector<FrequentItem> ivec;
   
  .....//填充vector操作

   
  现在要将vector中的结构体逐个写入文件
   
  FILE *fp=new FILE;
if((fp==fopen("..\\History\\FrequentItem.dat","wb"))==NULL)
return;
for(std::vector< FrequentItem >::iterator iter=ivec.begin();iter!=ivec.end();iter++)
{
strcpy(buf.szName,(*iter).szName);
buf.nCount=(*iter).nCount;
fwrite((void*)&buf,sizeof(FrequentItem),1,fp); //问题所在。。。
memset((void*)&buf,0,sizeof(FrequentItem));
}
fclose(fp);


为什么程序运行到fwrite时就出现异常,具体提示贴出来如下
project Project1.exe raised exception class EAccessViolation with message 'access violation at address 
3250b319 in module ' cc3250mt.dll' Read of address 00000060',process stopped Use step or run tu continue.”

问题出在哪里,以前都是用VC写程序,很少用C++Builder,希望达人解惑!

------解决方案--------------------
出错是因为你的fp指针没有正确赋值。

FILE *fp=new FILE;
if((fp==fopen("..\\History\\FrequentItem.dat","wb"))==NULL)
return;
改成;
C/C++ code
FILE *fp = fopen("..\\History\\FrequentItem.dat","wb");
if (fp == NULL)
    return;