title: Why does my program crash if I don't give command line arguments to it?
body: <p>I made a simple test program to play around with C++11 threads.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;thread&gt;
  using namespace std;
  
  void tee(int civ)
  {
      for(int loop=0; loop&lt;19; loop++, civ++)
      {
          civ = civ%19;
          cout &lt;&lt; loop &lt;&lt; "\t" &lt;&lt; civ &lt;&lt; endl;
          this_thread::sleep_for(chrono::milliseconds(300));
      }
  }
  
  void koot()
  {
      while(true)
      {
          cout &lt;&lt; ":) ";
          this_thread::sleep_for(chrono::milliseconds(300));
      }
  }
  
  int main(int argc, char *argv[])
  {
      thread saie(tee, atoi(argv[1])),
          kamaa(koot);
      saie.join();
      kamaa.join();
  
      return 0;
  }
  </code></pre>
  
  <p>It works fine as long as I supply command line arguments, but if I don't, it crashes.
  How can this be solved?
  I tried checking the argument count, and if they existed, to no avail.</p>
  
  <p>EDIT: I had to add this line:</p>
  
  <pre><code>if(argc &lt; 2) return 1;
  </code></pre>