asked on
void myProgram
{
CStdioFile file;
CString szPath = _T("Myfile.txt");
CString szData,szError;
bool bFound = false;
int nErrors = 0;
TCHAR szCause[255];
try
{
file.Open(szPath, CFile::modeNoTruncate | CFile::modeReadWrite);
file.SeekToEnd();
while( file.ReadString(szData) && !bFound && !nErrors )
{
if( szData.Find(_T("MyName="),0) >= 0 )
{
someProcessProgram(szData);
bFound = true;
}
}
file.Close();
}
catch( CException* e )
{
e->GetErrorMessage(szCause,255);
e->Delete();
szError.Format(_T("An exception occurred while reading data.\nWindows reports: %s"),szCause);
nErrors++;
AfxMessageBox(szError);
}
catch( std::exception* e )
{
szError.Format(_T("An exception occurred while reading data.\nWindows reports: %s"),e->what());
nErrors++;
AfxMessageBox(szError);
}
catch(...)
{
szError = _T("An exception occurred while reading data.");
nErrors++;
AfxMessageBox(szError);
}
}
ASKER
C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.
TRUSTED BY