#include <iostream>
using namespace std;

class ch_stack {
public:
  explicit ch_stack (int size) : max_len(size), top(EMPTY) {
    s = new char[size];
  }// end of ctor

  void reset() {
    top = EMPTY; 
  }

  void push( char c) { 
    s[++top] = c; 
  }
  
  char pop() {
    return s[top--]; 
  }

  char top_of() const {
    return s[top];
  }
   
  bool empty() const {
    return (top == EMPTY);
  }
   
  bool full() const {
    return (top == max_len - 1);
  }

private:
  enum{EMPTY = -1};
  int max_len;
  char *s;
  int top;
};

  int main() {

    ch_stack s(200);
    char str[40] = { "hello world" };
    int i = 0;

    cout << "string = " << str << endl;

    s.reset();
    while( str[i] && ! s.full() ) {
      s.push( str[i++] );
    }

    cout << "reversed string= ";

    while (! s.empty() ) {
      cout << s.pop();
    }

    cout << endl;
  }



