title: How to export error-handling to a function in C using <errno.h>
body: <p>I am checking if user enters the correct number and type of cmd arguments when calling main.</p>
  
  <p>I thought it would be a great idea to write a function, which prints out some text, so I can reuse it when checking for <code>NULL</code> pointers. I included <code>&lt;errno.h&gt;</code>.</p>
  
  <pre><code>void errcall()
  {
    perror("Error printed by perror()");
    exit(EXIT_FAILURE);
  }
  </code></pre>
  
  <p>Then I wrote a function to check if arguments are right and sufficient.</p>
  
  <pre><code>void err_cmd_handle(int argc_input)
  {
    if(argc_input==1 || argc_input&gt;2)
      errcall(); 
  }
  </code></pre>
  
  <p>When I call this in main, giving <code>int argc</code> as an argument to <code>err_cmd_handle()</code>, then I get a success, even when I did not give <em>any</em> arguments besides starting the program. Why does the condition fail to check correctly?</p>
  
  <pre><code>int main(int argc,char* argv[])
  {
    err_cmd_handle(argc);
    return 0;
  }
  </code></pre>