title: How to use C I/O redirection on a Mac?
body: <p>I'm experimenting with I/O redirection in C; I redirect the Standard Input so that I can print a number contained in a txt file on the console.</p>
  
  <pre><code>int main() {
      int number;
      scanf("%d", &amp;number);
      printf("The number is %d.", number);
  }
  </code></pre>
  
  <p>In Xcode, I go the Products folder and I double click on the executable file to fire up a console. I issue this line:</p>
  
  <pre><code>./main.c &lt; number.txt
  </code></pre>
  
  <p>The console prints out a number, but not the correct one. If you wish, download this simple project <a href="https://www.dropbox.com/s/q7sgpt4xl8ahuad/StackOverflow_Question.zip?dl=0" rel="nofollow noreferrer">here</a>. What am I doing wrong here?</p>
  
  <p><img src="https://i.imgur.com/R3CgEWL.gif" alt=""></p>
  
  <p><strong>Updates</strong></p>
  
  <ul>
  <li>I'm experiencing the same issue with a <code>CSV</code> file;</li>
  <li>I checked the return value of <code>scanf()</code> and it's equal to 0.</li>
  <li>The number contained in the files is <code>4</code> (I changed it into <code>5</code> recently), but the output of the shell is <code>The number is 1726119990.</code></li>
  </ul>