This Text file is old! In a 🏛️Museum, an unsorted archive of (user-)pages. (Saved from Geocities in Oct-2009. The archival story: oocities.org)
--------------------------------------- (To 🚫report any bad content: archivehelp @ gmail.com)
>

// wordcount.cpp - parses the words out of a text (like strtok) 
// (based on program in Eckels, Thinking in C++), 
// lowercases them, and inserts
// them into a map to count them.
// 
#pragma warning(disable:4786)
#include "require.h"
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

typedef map > Wordcount;
Wordcount wc;
//vector tosort;

void print_word(Wordcount::value_type& entry)
{
	cout << entry.first << ": " << entry.second << "\n";
}

void lc(string& s) {
   char ch[2]; 
   string s2 = s;
   s.erase();
   string::iterator p = s2.begin();

   while(p != s2.end()) {
      ch[0] = (char) tolower(*p);
      ch[1] = '\0';
      s.append(ch);
      p++;
   }
}

double& value(string& s) {
   // convert word to lowercase
   lc(s);
   // if wc[s] exists return it.
    if (wc.find(s) != wc.end()) {
       return wc[s];
    }
   // if it doesn't exist insert it
   wc[s] = 0;
   return wc[s];
}


void main(int argc, char* argv[]) {
  using namespace std;
  requireArgs(argc, 1);
  ifstream in(argv[1]);
  assure(in, argv[1]);

  istreambuf_iterator p(in), end;
  int i = 0;
  while (p != end) {
    string word;
    insert_iterator 
      ii(word, word.begin());

    // Find the first alpha character:
    while(!isalpha(*p) && p != end) {
      p++;
      i++;
    }

    // Copy until the first non-alpha character:
    while (isalpha(*p) && p != end) {
      *ii++ = *p++;
      i++;
    }

    if (word.size() != 0) {
       value(word)++;
       //cout << i << ";";
    }

  } 
   
  //for_each(wc.begin(),wc.end(),print_word);

  cout << endl;
  Wordcount::iterator it = wc.begin();
  while (it != wc.end()) {
     cout << (*it).first << ":" << (*it).second << endl;
     it++;
  }

} 

Text file Source (historic): geocities.com/soho/square/3472

geocities.com/soho/square
geocities.com/soho

(to report bad content: archivehelp @ gmail)