#include <iostream>
using namespace std;

class ch_stack {
public:

  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, max_len = 100, FULL = max_len -1};
  char s[max_len];
  int top;
};

  int main() {

    ch_stack s;
    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;
  }



