title: how to read file and print in reverse order using stack C++
body: <p>I have to read text file each word at a time and then push that word to stack and then pop each word at a time to print in the display. I have tried the following code but after running the program, compiler just shows the blank screen with no error. 
  NOTE: 
  I am not allowed to implement the stack using a class or struct or with STL. The stack must be implemented using a fixed size array of words and an index integer for indicating the top of the stack</p>
  
  <p>My text file is something like:</p>
  
  <pre><code>one two three four five
  six seven and so on
  </code></pre>
  
  <p>output should be:</p>
  
  <pre><code>no os dna neves xis ...
  </code></pre>
  
  <p>main.cpp</p>
  
  <pre><code>using namespace std;
  
  char word;
  void push(char);
  void pop();
  void displaywords();
  
  int count = 0;
  const int arr_Size=50;
  string stack[arr_Size];
  
  int main()
  {
      //string word;
      ifstream infile;
      infile.open("data.txt");
      if(!infile)
      {
          cerr &lt;&lt; "An error occurred while opening the file.";
          exit(1);
      }
  
      do
      {
          cin &gt;&gt; word;
          if (infile.fail())
              break;
          cout &lt;&lt; word;   
          push(word);     
      }while(infile.eof());
      infile.close();
  
      while(stack!=NULL) // trying to write code for stack is not null
      {
          displaywords();
          pop();
      }
      return 0;
  }
  
  void push(char word)
  {
      count = count + 1;
      stack[count] = word;
  }
  
  void displaywords()
  {
      cout &lt;&lt; "PUSHED " &lt;&lt; " " &lt;&lt; stack[count] &lt;&lt; "   ." &lt;&lt; endl;
  }
  
  void pop()
  {
      count = count - 1;
  }
  </code></pre>