title: stack size by user
body: <p>I am trying to have my stack be dynamically allocated based on the number of letters a user inputs.</p>
  
  <p>My current program gets a set of letters or numbers then output them in FILO order (thus reverse order).</p>
  
  <p>For example, if a user inputs 123, it sets the size of stack to 3 and returns 321.</p>
  
  <p>This is my header (class)</p>
  
  <pre><code>class CharStack {
      enum {size = 100};      //size of stack. big enough to receive long letters.
      int top;                //top pointer 
      char buf[size];         //stack's size
  
      public:
  
      CharStack()             //constructor
          {top = size;}
  
      bool chkEmpty() const   //true if no data in stack
          {return top == size;}
      bool chkFull() const    //true if stack is full
          {return !top;}
      bool push(char ch);     //pop data from stack
      char pop();
  };
  </code></pre>
  
  <p>and this is my main.</p>
  
  <pre><code>int main()  {
      CharStack chStack;              //A stack with 100
      char str[100];
      int *size;
  
      cout &lt;&lt; "input letter or numbers:";
      cin &gt;&gt; str;
      size = new int[strlen(str)+1];  //count number of letters.
  </code></pre>
  
  <p>and so on...</p>
  
  <p>I think all I need to do from here is to set <code>size (in main) =  buf[size]</code> (in the header file).  I believe there's a very simple way to solve this, but I just don't see it.</p>