面试题:下面代码的功能,尤其是try、fwrite 和 catch 的那几句,能加点注释吗?谢谢,急!
fwrite((const char*)&m_fFileVersion, 1,4,(FILE*)m_ofs_isfFile);
这语法好难,谁细致点剖析下
try
{
//以创建、写方式打开文件
//m_isfFile.Open(strFileFullName, CFile::modeCreate | CFile::modeWrite);
//m_txtFile.Open(((CString)strFileFullName)+".txt", CFile::modeCreate | CFile::modeWrite| CFile::shareDenyNone);
m_ofs_isfFile = NULL;
//fopen_s(&m_ofs_isfFile,strFileFullName,"wb");
m_ofs_isfFile = _fsopen(strFileFullName, "wb",_SH_DENYNO );
if (NULL == m_ofs_isfFile)
{
//打开文件失败。
return false;
}
sprintf_s(strFileFullName,1500,"%s.txt",strFileFullName);
m_ofs_txtFile = NULL;
//fopen_s(&m_ofs_txtFile,strFileFullName,"w_SH_SECURE");
m_ofs_txtFile = _fsopen(strFileFullName, "w",_SH_DENYNO );
//m_ofs_txtFile = (FILE*)CreateFile(strFileFullName, GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (NULL == m_ofs_txtFile)
{
//打开文件失败。
return false;
}
m_bIsFileOpened = true;
fwrite(m_pszFileHeader, 1,10,(FILE*)m_ofs_isfFile);
fwrite((const char*)&m_fFileVersion, 1,4,(FILE*)m_ofs_isfFile);
fseek((FILE*)m_ofs_isfFile,(LONGLONG)64, 0);
fwrite((const char*)&m_ulFileTickCount, 1,4,(FILE*)m_ofs_isfFile);
fwrite((const char*)&m_stFileCreateTime, 1,16,(FILE*)m_ofs_isfFile);
}
//catch (CException *e)
catch (...)
{
//e->GetErrorMessage(m_pszErrorDescription,OMT_MAX_ERROR_DESCRIPTION,NULL);
//e->Delete();
return false;
}
return true;