Opening and Analyzing a HTML Document

I'm really struggling in this class and just need help completing this code project. I don't completely get what is wrong with it. Can someone please help. It would be greatly appreciated.

#include <iostream>
#include <fstream>
#include <string>

using namespace std;

int main ();
{
const char TAG = '<', //represents the beginning of a tag
LINK = 'a', //represents the beginning of a link
COMMENT = '!'; //represents the beginning of a comment
char fileChar; //individual characters from the file
int totalChars = 0, //total characters in the file
totalTags = 0, //total tags in the file
totalLinks = 0, //total links in the file
totalComments = 0; //total comments in the file
string fileName; //the filename that is input from the user
ifstream inFile;

cout << "========================================" << endl; //print an overall title
cout << "HTML File Analyzer" << endl;
cout << "========================================" << endl << endl;

cout << "Enter a valid filename (no blanks!): "; //ask the user to input filename
cin >> fileName; //user inputs the filename

inFile.open (fileName.c_str()); //the file is opened

while (!inFile) //if filename is not valid
{
inFile.clear(); //then clear the file
cout << endl << "Re-enter a valid filename: " << endl; //and ask the user to reenter a valid filename
cin >> fileName; //user inputs new filename
inFile.open (fileName.c_str()); //open file if filename is valid
}

cout << "========================================" << endl; //print header for the text of the file
cout << "Text of the File";
cout << "========================================" << endl;

inFile.get(fileChar); //get individual characters from the file
cout << fileChar; //display the individual character on the screen

while(inFile) //while the file is open
{
getline(inFile, line); //get each line from the file
cout << line << endl; //and print the lines on the screen
totalLines++;
}

cout << "========================================" << endl; //print the end of text message
cout << "End of the Text" << endl;
cout << "========================================" << endl << endl << endl;

while(inFile)
{
if(fileChar == TAG)
{
totalTags++;
if(fileChar == COMMENT)
totalComments++;
else if(fileChar == LINK)
totalLinks++;
}

inFile.get(fileChar);
cout << fileChar;
totalChars++;
}

cout << "Analysis of File" << endl;
cout << "----------------" << endl << endl;
cout << "Number of Lines: " << totalLines << endl;
cout << "Number of Tags: " << totalTags << endl;
cout << "Number of Comments: " << totalComments << endl;
cout << "Number of Links: " << totalLinks << endl;
cout << "Number of Chars in File: " << totalChars << endl;
cout << "Number of Chars in Tags: " << endl;
cout << "Percentage of Characters in Tags: " << endl;

inFile.close ();
return (0);
}

Topic archived. No new replies allowed.