title: How to view the output of c++ program which compiled on terminal
body: <pre><code>#include&lt;iostream&gt;
  using namespace std;
  
  int main()
  {
      freopen("input.txt","r",stdin);
      freopen("output.txt","w",stdout);
  
      int a,b;
      cin &gt;&gt; a &gt;&gt; b;
      cout &lt;&lt; a+b;    
      return 0;
  }
  </code></pre>
  
  <p>When I compile it from terminal(Mac), it is not read meaning from input.txt and do not write to output.txt. What is the problem?</p>