Thank you so much for helping me! Everyone is so fast and excellent! Thanks again!
What is happening is no data is being written to my file, after I test this code. Just a 0 appears.
What am I doing wrong?
void CreateHtmlFile(string myMessages[])
{
int i = 0;
int emptyarray = 0;
int myEmptyCounter = 0;
int emptyArrayCounter = 0;
string myEmpty;
ofstream myfile;
myfile.open ("C:\\Users\\Andrews\\Documents\\Visual Studio 2010\\Projects\\computerclass\\Debug\\outages.htm", ios::out);
if(!myfile) // is there any error?
{
cout << "Error opening the file! Aborting…\n";
exit(1);
}
myfile << "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
myfile << "<html>\n";
myfile << "<head>\n";
myfile << "<title>Livermore Readerboard</title>\n";
myfile << "<style type='text/css'>\n";
myfile << "table {font-family:Helvetica Narrow, sans-serif;font-size:42px;}\n";
myfile << "body\n";
myfile << "{\n";
myfile << "text-align: center;\n";
myfile << "background: #000000;\n";
myfile << "color:#00FF00;\n";
myfile << "}\n";
myfile << "#container\n";
myfile << "{\n";
myfile << "margin-left: auto;\n";
myfile << "margin-right: auto;\n";
myfile << "width: 93em;\n";
myfile << "text-align: left;\n";
myfile << "</style>\n";
myfile << "<META HTTP-EQUIV= \"refresh\" content= \"5;URL=readerboard.htm\">\n";
myfile << "</head>\n";
myfile << "<body>\n";
myfile << "<div id='container'>\n";
myfile << "<table class='Design6' border=1 cellpading=1 cellspacing=0>\n";
myEmpty.clear();
while (i != 10)
{
if (myMessages[i] != "")
{
myfile << "<tr>\n";
myfile << "<td><b>" << myMessages[i] << "</b></td>\n";
myfile << "</tr>\n";
i++;
}
else
{
i++;
emptyArrayCounter++;
}
}
if (emptyArrayCounter == 9)
{
//empty array so insert default message
myfile << "<tr>\n";
myfile << "<td><b>" << "No Outages" << "</b></td>\n";
myfile << "</tr>\n";
}
myfile << "</div>\n";
myfile << "</body>\n";
myfile << "</html>\n";
myfile.close();
}