title: Segmentation Fault With argv
body: <p>I have a program that reads in a single argument from the command line and performs certain operations on it. I'm using argv and argc. When I fail to pass an argument to the program, it segfaults. I've tried checking if argc isn't a certain value and then printing the value out, but it still segfaults. Here's the code in question. Note that it works as expected when passed a single argument. Here's the code in question:</p>
  
  <pre><code>int main(int argc, char *argv[])
  {
  
  int numTimes = atoi(argv[1]);           //converts content of argv[1] into integer
  
  if(argc != 2)
  {
          printf("Enter a valid integer.");
  }
  </code></pre>