My code:
Functionality: It is a function expects a three arguments and create a file.
void performLog(string strStoredProcName, int nCount, double time)
{
int tme=(int) time;
int hour=tme/3600;
tme=tme%3600;
int min=tme/60;
tme=tme%60;
int sec=tme;
char *StrLen;
int len = 0;
int lenpass = 0;
StrLen = &strStoredProcName[0];
len = strlen(StrLen);
lenpass = 41 - len;
fstream outFile( "Perform.out", ios_base::out | ios_base::app );
if ( ! outFile )
{
cerr << "Cannot open 'Perform.out' for output" << "\n" << endl;
exit(-1);
}
if (paramLogCreation == false)
{
outFile << "**************Performance Log*********************" << "\n" << endl;
outFile << "DB Type: MYSQL" << "\n" << endl;
outFile << "-----------------------------------------------------------------------------------------" << "\n" << "\t" << "\t" << "\t" << "\t" << "Stored Procedure Statitics" << "\n" << endl;
outFile << "-----------------------------------------------------------------------------------------" << "\n" << endl;
outFile << "Store Procedure Name" << setw(30) << "Execution Count" << setw(30) << "Time Taken to Execute" << "\n" << endl;
paramLogCreation = true ;
}
outFile << strStoredProcName << setw(lenpass) << nCount << setw(20) <<hour<<"::"<<min<<"::"<<sec <<"\n" << endl;
outFile.close();
}
Here i am writing a unit test cases, for the code , which i have written, This function is one of the functions in that. Please help me , how to resolve this issue. Please i am very new one to the C++ and need to know the where i committed mistake.