title: Stack C++. One element not displayed
body: <p>The program reads a text file with the contents</p>
  
  <pre><code>A  DPX 
  
  A  QRT
  </code></pre>
  
  <p>Pushes DPX and QRT on stack. But while displaying stack{void show()}, it does not display stack[0]. No idea Why!? It is being pushed onto the stack. element stack[0] diplayed in push() but not in show()</p>
  
  <pre><code>const int MAX = 10 ;
  struct car
  {
          char * lPlate;
          int moves;
  };
  
  class garage
  {
      private :
  
          char * stack[MAX] ;
          int top ;
  
      public :
              garage( )
              {
                 top = -1 ;
              }
  
          void arrive(struct car  c)
           {
              push(c.lPlate);
           }
  
          void depart(struct car c )
           {
  
           }
  
          void push ( char * item ) ;
          char* pop( ) ;
          void show();
  } ;
  
  void garage:: push ( char* item )
  {
      if ( top == MAX - 1 )
           cout &lt;&lt; endl &lt;&lt; "Sorry. Parking lot is full" ;
      else
      {
          top++ ;
          strcpy(stack[top] , item) ;
      }
      cout&lt;&lt;"In push: "&lt;&lt;stack[top];
  }
  
  char * garage:: pop( )
  {
    if ( top == -1 )
      {
          cout &lt;&lt; endl &lt;&lt; "Parking lot empty is empty" ;
          return NULL ;
      }
  
      return stack[top--] ;
  }
  
  void garage:: show()
  {
     cout&lt;&lt;" \nParking Lot Status:\n";
     if( top == -1 )
      {
          cout &lt;&lt; endl &lt;&lt; "Parking lot is empty" ;
          return ;
      }
      int i=top;
      cout&lt;&lt;"In show "&lt;&lt;stack[0]&lt;&lt;endl;
      while(i&gt;-1)
      {
       cout&lt;&lt;stack[i]&lt;&lt;endl;  i--;
      }
  }
  int main()
  {
      clrscr();
      char *action;
      garage  g;
      ifstream fin("TEST");
      if(!fin){cout&lt;&lt;"Cannot open i/p file \n\n";return 1;}
      char str1[80],str2[40]; int i,j;
      while(!fin.eof())
      {
       fin.getline(str2,MAX);
       struct car c;//create a car obj
       char * pch;
       pch = strtok (str2," ,.-");//split string on getting &lt;space&gt;/&lt;,&gt;/&lt;.&gt;/&lt;-&gt;
      while (pch != NULL)
      {
        action=pch;
  
       pch = strtok (NULL, " ,.-");
       c.lPlate=pch;
       pch=NULL;
       cout&lt;&lt;"\nAction: "&lt;&lt;action&lt;&lt;" lPlate: "&lt;&lt;c.lPlate&lt;&lt;"\n";
        switch(*action)
        {
          case 'A':
              g.arrive(c);
              break;
          case 'D':
              g.depart(c);
              break;
          }
      }
      cout&lt;&lt;"\n\n";
      }
  
          fin.close();
          cout&lt;&lt;"\n";
          g.show();
      getch();
  }
  </code></pre>