?? fileoperation.h
字號:
// fileoperation.h: interface for the Cfileoperation class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_FILEOPERATION_H__05819236_652F_4757_A8F0_C0E881770456__INCLUDED_)
#define AFX_FILEOPERATION_H__05819236_652F_4757_A8F0_C0E881770456__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
template <class t>
class Cfileoperation
{
public:
Cfileoperation() { ;}
virtual ~Cfileoperation() {;}
int openfile(char* m_path,char* m_param,t m_tem[]);
int openfile(char* m_path,char* m_param,t m_tem[], int length);
void savefile(char* m_path,char* m_param,t m_tem[],int m_length);
void savefilename(char* m_path,char* m_param,t m_tem[],int m_length);
};
template <class t>
int Cfileoperation<t>::openfile(char* m_path,char* m_param,t m_tem[])
{
FILE *m_file;
m_file=fopen(m_path,m_param);
if(m_file==NULL)
{
AfxMessageBox(IDS_OPEN_FILE);
return 0;
}
ZeroMemory(m_tem, sizeof(t)*120);
for(int i=0; ;i++)
{
if(fread(&m_tem[i],sizeof(t),1,m_file)!=1)
{
fclose(m_file);
return i;
}
}
fclose(m_file);
}
template <class t>
int Cfileoperation<t>::openfile(char* m_path,char* m_param,t m_tem[], int length)
{
FILE *m_file;
m_file=fopen(m_path,m_param);
if(m_file==NULL)
{
AfxMessageBox(IDS_OPEN_FILE);
return 0;
}
ZeroMemory(m_tem, sizeof(t)*length);
for(int i=0; ;i++)
{
if(fread(&m_tem[i],sizeof(t),1,m_file)!=1)
{
fclose(m_file);
return i;
}
}
fclose(m_file);
}
template <class t>
void Cfileoperation<t>::savefile(char* m_path,char* m_param,t m_tem[],int m_length)
{
FILE *m_file;
m_file=fopen(m_path,m_param);
if(m_file==NULL)
{
AfxMessageBox(IDS_WRITE_FILE);
}
for(int i=0;i<m_length;i++)
{
if(fwrite(&m_tem[i],sizeof(t),1,m_file)!=1)
{
fclose(m_file);
return;
}
}
fclose(m_file);
}
template <class t>
void Cfileoperation<t>::savefilename(char* m_path,char* m_param,t m_tem[],int m_length)
{
FILE *m_file;
m_file=fopen(m_path,m_param);
if(m_file==NULL)
{
AfxMessageBox(IDS_WRITE_FILE);
}
for(int i=0;i<m_length;i++)
{
if(!strcmp(m_tem[i].name,"")) continue;
if(fwrite(&m_tem[i],sizeof(t),1,m_file)!=1)
{
fclose(m_file);
return;
}
}
fclose(m_file);
}
#endif // !defined(AFX_FILEOPERATION_H__05819236_652F_4757_A8F0_C0E881770456__INCLUDED_)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -