title: Problem with the Caesar problem set on cs50 online course
body: <p>I'm on the stage where we need to correctly setup the command line argument to take only digits and to break out of the code if the user types anything else other than a digit. (leaving it empty, inputting two digits, inputting text, inputting two pieces of text etc.)</p>
  <p>So I made the program work correctly if the user types more than one command line argument or one command line argument which isn't a digit. My problem is that if I leave the command line argument blank the program gives me a segmentation fault and it doesn't work as intended if I type a single command line like &quot;1d&quot;. Can anyone tell me where I went wrong? I'm stuck. Here's the code:</p>
  <pre><code>#include &lt;cs50.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;string.h&gt;    
      
  bool only_digits(string argv[]);
  int main(int argc, string argv[])
  {
      bool digits = only_digits(argv);
      if(argc != 2 || digits == false)
      {
          printf(&quot;Usage: ./caesar key\n&quot;);
          return 1;
      }
      else
      {
          return 0;
      }
  }
  bool only_digits(string argv[])
  {
      bool digit = false;
      for(int i = 0; i &lt; strlen(argv[1]); i++)
      {
          if(isdigit(argv[1][i]))
          {
              digit = true;
          }
      }
      return digit;
  }
  </code></pre>
  <p><a href="https://i.stack.imgur.com/qJmwd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qJmwd.png" alt="Here are all my inputs" /></a></p>