--- stringclass.cpp	2003-05-21 19:43:02.000000000 -0400
+++ stringclass-new.cpp	2003-05-21 20:08:55.000000000 -0400
@@ -1,6 +1,8 @@
 #include <iostream>
 using namespace std;
 
+char *my_strdup(const char *src);
+
 class String {
 
 private:
@@ -62,13 +64,40 @@
 	return matches;
 }
 
-void main () {
+int main(int argc, char *argv[]) {
   String myString;
   int matches;
+  char buf[BUFSIZ];
   
   myString.Set("THISIS REALLY IS A REALLY BIG STRING TEST!!!");
   myString.Print();
   matches = myString.Match("REALLY");
   cout << "matched " << matches << " times." << endl;
+  cin.getline(buf, sizeof(buf));
+  myString.Set(my_strdup(buf));
+  printf("buf = \"%s\"\n", buf);
+
+}
+
+char *my_strdup(const char *src) {
+  int i, len;
+  char *ret = NULL;
 
+  if (!src)
+    return NULL;
+
+  len = strlen(src);
+  ret = (char*) malloc(len + 1);
+  if (!ret)
+    return NULL;
+
+  /* the fast and easy way */
+  /* memcpy(ret, src, len + 1); */
+
+  /* the bullshit slow way */
+  for (i = 0; i < len; i++)
+    ret[i] = src[i];
+  ret[len] = '\0';
+  
+  return ret;
 }

