Original Post
Ok, it seems to stop writing to the file haveway through my function... heres the code, ive written all the main stuff in the middle but cant debug it since I have no output... so dont complain if im doing something wrong thats not file related
//--------------------------
// Function: BuildOutputCpp()
// Inputs: filename - file to save to
// Outputs: None
//
// Description: Parses this->pszOutput and saves resultent HTML file
//--------------------------
void BuildOutputCpp(char* filename, char* pszOutput, int iSize, char* pszTitle)
{
ofstream File(filename, ios::binary);
if(!File)
{
File.close();
MessageBox(CApp.GetMainWnd(), "BuildProjectFile() failed", "Error", MB_ICONERROR | MB_OK);
return;
}
char szWord[200];
bool bEnterWord = false;
bool bCopy = false;
char* pszCode = 0;
int iLen;
// Headers
File.write((char*)"<html>\r\n<head>\r\n <title>", strlen("<html>\r\n<head>\r\n <title>"));
File.write((char*)pszTitle, strlen(pszTitle));
File.write((char*)"</title>\r\n</head>\r\n\r\n", strlen("</title>\r\n</head>\r\n\r\n"));
File.write((char*)"<body bgcolor=\"#FFFFFF\" text=\"#000000\">\r\n", strlen("<body bgcolor=\"#FFFFFF\" text=\"#000000\">\r\n"));
File.write((char*)"<font size=\"3\"><br>\r\n", strlen("<font size=\"3\"><br>\r\n"));
// Preceeding code
if(SendMessage(GetDlgItem(CApp.GetMainWnd(), IDC_CHECKADDPRECEEDING), BM_GETCHECK, 0, 0) == BST_CHECKED)
{
iLen = GetWindowTextLength(GetDlgItem(CApp.GetMainWnd(), IDC_EDIT3));
if(iLen != 0)
{
pszCode = new char[iLen+1];
GetWindowText(GetDlgItem(CApp.GetMainWnd(), IDC_EDIT3), pszCode, iLen+1);
File.write((char*)pszCode, strlen(pszCode));
File.write((char*)"\r\n\r\n", strlen("\r\n\r\n"));
delete[] pszCode;
}
}
/////////// NOTHING WRITTEN TO FILE AFTER HERE ///////////
for(int i = 0; i < iSize; i++)
{
// Check to see if its the beggining of a word
for(int k = 66; k < 90; k++) // a - z
{
if(pszOutput[i] == k)
{
bEnterWord = true;
break;
}
}
if(!bEnterWord)
{
for(int e = 97; e < 122; e++) // A - Z
{
if(pszOutput[i] == e)
{
bEnterWord = true;
break;
}
}
}
// Ok a word has started
if(bEnterWord)
{
szWord[0] = pszOutput[i++];
// Get the word
for(int u = 0;; u++, i++)
{
bCopy = false;
// Check if its a valid character
for(int r = 66; r < 90; r++) // a - z
{
if(pszOutput[i] == r){bCopy = true; break;}
}
if(!bCopy)
{
for(int k = 97; k < 122; k++) // A - Z
{
if(pszOutput[i] == k){bCopy = true; break;}
}
}
// if its a vaild char then copy it else its the end of the word
if(bCopy) szWord[u] = pszOutput[i];
else
{
szWord[++u] = ''\0''; // Attach NULL
break;
}
}
// The word is now stored in szWord
// Check it to see if we need to color code it
if(IsReservedCpp(szWord))
{
File.write((char*)"<font color=\"#0000FF\">", strlen("<font color=\"#0000FF\">"));
File.write((char*)szWord, strlen(szWord));
File.write((char*)"</font>", strlen("</font>"));
}
else File.write((char*)szWord, strlen(szWord));
}
else File.write((char*)pszOutput[i], 1);
bEnterWord = false;
}
// Appendage code
if(SendMessage(GetDlgItem(CApp.GetMainWnd(), IDC_CHECKADDAPPENDAGE), BM_GETCHECK, 0, 0) == BST_CHECKED)
{
iLen = GetWindowTextLength(GetDlgItem(CApp.GetMainWnd(), IDC_EDIT4));
if(iLen != 0)
{
pszCode = new char[iLen+1];
GetWindowText(GetDlgItem(CApp.GetMainWnd(), IDC_EDIT4), pszCode, iLen+1);
File.write((char*)pszCode, strlen(pszCode));
File.write((char*)"\r\n\r\n", strlen("\r\n\r\n"));
delete[] pszCode;
}
}
File.write((char*)"</font>\r\n</body>\r\n</html>", strlen("</font>\r\n</body>\r\n</html>"));
File.close();
}