I want my program to recognize tags, comments, and links in a html file. How would I get the program to read and count what I'm looking for? For example, if the html file has three links, how do I get my program to count it?
Also, how would I output the results to a text file?
This is what I got so far.

#include <iostream>
#include <string>
#include <fstream>
 
using namespace std;
 
 
int main()
{
	ifstream inFile;
	string filename,

	const char SPACE = ' ';

	int lines = 0 ,
	tags = 0,
	comments = 0,
	links = 0,
	fileChar = 0,
	tagChar = 0;

	double percent;


  cout << "Please enter a filename ->";
  cin >> filename;
 
  inFile.open(filename.c_str());
 
  while(!inFile)
  {
          inFile.clear();
          cout << "Incorrect Filename..." << endl;
 
          cout << "Please re-enter a filename ->";
          cin >> filename;
 
          inFile.open(filename.c_str());
  }
 
  getline(inFile, tags);
  while(inFile)
  {
          inFile >> tags ;

          cout << filename;


          for(int i = 0; i < num; ++i)
          {
 
                  if ( tags == '<')
                  {                          
                          tags++;
                          
                          if(links == '<a')
                          {
                                 links++;
                          }
                          else(comments == '<!')
                          {
                                   comments++;
                          }
                          
                          if(fileChar != space)
                          {
                                     fileChar++;
                          }
                          else
                  }
                  else
                  {
                      cout << "** This dataline invalid **" << endl; //format
                  }       
 
          }
          
          //Calculations
          
          
          // Final Stats
		    cout << "Number of lines: " << lines << endl;
			cout << "Number of tags: " << tags << endl;
			cout << "Number of comments: " << comments << endl;
			cout << "Number of links: " << links << endl;
			cout << "Number of chars in file: " << filChar << endl;
			cout << "Number of chars in tags: " << tagChar << endl;
			cout << "Percentage of characters in tags: " << endl;
          
          inFile.ignore(80, '\n');
          getline(inFile, title);
  }
 
  inFile.clear();
  inFile.close();
 
 
  return 0;
}

I'm confused. "tags" is an int (line 16), and you're reading into like it's a string (line 41) and you're trying to compare it to multiple characters (line 56) within a spot for a single character (single quotes).

I'd say grab a good book and spend at least a week or so going through some of the basics.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.