From: dwo1@gte.com (Donald W. Ottens)
Newsgroups: comp.lang.c++
Subject: read stdin & output list of unique words
Date: 28 Jul 92 20:36:46 GMT
Organization: GTE Laboratories Incorporated, Waltham MA

Hi all,

I am new at c++ (and fairly new to c).  I wish to write a program
that reads from standard input and outputs a list of all unique words
from the input, ranked in lexical order, and preceded by a count of the 
number of times the words occurred in the input stream. 

Obviously, I am stuck *disappointed that I can't get it*

I was wondering if anybody would be available for some
help (tutoring via email), as this is a homework assignment, 
and I need to get it done quickly.

I am new on newsnet, so please don't flame me if asking for tutoring
in this manner is not right (I am basically in need of guidance, considering
my limited time to get this done).  Just tell me if I am doing something
wrong and I'll back off.

So far, this is what I have done (see following). I must add that I have
plenty of text books, which I have referenced and they don't seem to
clearly explain some basic concepts

If there is anyone out there that can assist, please respond, and I will
be indebted to you (perhaps, one day I can return the help).

Thank you.

don o
**********************

#include <string.h>
#include "String.h"
#include <iostream.h>


class string {                     // class for holding words
        char *p;
        int size;
public:
        string(const char *str);
        string(const string &o);
        ~string();
        print();
        int rank(const string *);
        int rank(const char *);
};

string::string(const char *str)       // init using c-like quoted str
{
  size = strlen(str) + 1;    // room for null terminator
  p = new char[size];
  if(!p)  {
    cout << "Allocation error\n";
    exit(1);
  }
  strcpy(p, str);
}

string::string(const string &o)      // init using a str object
{
  size = o.size;
  p = new char[size];
  if(!)  {
    cout << "Allocation error\n";
    exit(1);
  }
  strcpy(p, o.p);
}

string::~string()
{
  delete p;                // frees memory pt-ed to by p
}

void string::print();
{

}

int string::rank(const string *)  // rank string objects
{
  int operator==(string &o)  {return !strcmp(p, o.p);}
  int operator!=(string &o)  {return strcmp(p, o.p);}
  int operator<(string &o)   {return strcmp(p, o.p);}
  int operator>(string &o)   {return strcmp(p, o.p);}
  int operator<=(string &o)  {return strcmp(p, o.p);}
  int operator>=(string &o)  {return strcmp(p, o.p);}
}

int string::rank(const char *)  // rank string objects & quoted strings
{
  int operator==(char *s)  {return !strcmp(p, s);}
  int operator!=(char *s)  {return strcmp(p, s);}
  int operator<(char *s)   {return strcmp(p, s) < 0;}
  int operator>(char *s)   {return strcmp(p, s) > 0;}
  int operator<=(char *s)  {return strcmp(p, s) <= 0;}
  int operator>=(char *s)  {return strcmp(p, s) >=0;}
}


class string_list {                // class for maintaining list of words
        *p1;
        int size1;
public:
        string_list(string *, string_list *);
        ~string_list();
        insert(const char *);
        get_next();
        print();
};

string_list::string_list(string *, string_list *)
{
}

string_list::~string_list()
{
  delete p1;
}

string_list::insert(const char *)
{
}

string_list * string_list::get_next()
{
}

void string_list::print();
{
}

const BUFSIZE = 256;
string str;

main()
{

        cout << "\n****************************************************\n";
        cout << "This program reads from standard input and outputs a  \n";
        cout << "list of all unique words in the input, ranked in      \n";
        cout << "lexical order, and preceded by a count of the number  \n";
        cout << "of times the word occurred in the input stream.       \n";
        cout << "****************************************************\n\n";

        printf("\nWelcome to the String Program!\n");

        char      buf[BUFSIZE];

        while(cin >> buf)  {



        }


        printf("\nEnd of the String Program!\n");
        printf("\n");

        return 0;
}
Newsgroups: comp.lang.c++,comp.lang.objective-c