写了以下的程序,但是函数一运行就会一直生成文件,电脑死机。
#define COUNT 360
#define DATABYTES 314
#define MAXN 10
//////////////////////////////////
{
char buf[COUNT*DATABYTES];
//char *p;
int i,n,j;
char bytes[DATABYTES];
FILE *f;
//char fn[256];
CString str,str1;
str1 =NetData ;
str = bytes;
int w = strcmp(str,str1);
if (w=0)
{
}
else
{
for (j=0;j<314;j++)
{
bytes[j]=NetData1[j];
}
while (1)
{
n=0;
for (i=0;i<COUNT;i++)
{
//采集一次数据到bytes[]中
memcpy((void *)(buf+i*DATABYTES),(void *)bytes,DATABYTES);
}
n++;
if (n>MAXN) break;
m_SysTime = CTime::GetCurrentTime();
CString
str1 = m_SysTime.Format("%Y")+m_SysTime.Format("%m")
+m_SysTime.Format("%d")+m_SysTime.Format("%H")
+m_SysTime.Format("%M")+m_SysTime.Format("%S");
CString strFileName ="Data\\"+str1+".STD";
//CFile file ;
f=fopen(strFileName,"wb");
if (NULL==f)
{
printf("无法创建文件%s!\n",strFileName);
}
fwrite(buf,DATABYTES,COUNT,f);
fclose(f);
}
}
}