title: CS50 - Credit Card Assignment; Segmentation fault
body: <p>Still working on it but when I try to run the program I keep getting the error. I'm very new to programming so can't even see any issues at this point.
  This is an assignment for the CS50 course; called credit card.</p>
  <p>Also any constructive comments would be highly appreciated :)</p>
  <p>Code is below.</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;cs50.h&gt;
  #include &lt;ctype.h&gt;
  #include &lt;string.h&gt;
  
  int main(int argc, string argv[])
  {
      int n = 0; //n is length of card number
      int i = 0; //i is the digit 
      int m = 0;
      int p = 0;
      string s = 0;
  
      do
      {
          printf(&quot;Card Number: \n&quot;);
          string s = GetString(); //card number
  
          n = strlen(s);
    
          printf(&quot;%s\n&quot;, s);
      
          for (i = 0; i&lt;n; i++)
          {
             if (i %2 == 0)
             {
                  m = ((s[i] - '1')*2);
                  if (m &lt; 10)
                  {
                      p = p + m;  //p is product m is numerical value
                  }
                  else
                  {
                      p = 1 + p + (m -10);
                  }
             }   
             else
             {
              p = p + (s[i] - '1');
             }
          }
          if (p % 10 ==0)
          {
              if (n == 15 &amp;&amp; s[1] == 3 &amp;&amp; (s[2] == 4 | s[2] == 7))
              {
                  printf(&quot;AMEX\n&quot;);
              }
              if (n == 16 &amp;&amp; s[1] == 5 &amp;&amp; (s[2] == 1 | s[2] == 2 | s[2] == 3 | s[2] == 4 | s[2] == 5))
              {
                  printf(&quot;MASTERCARD\n&quot;);
              }
              if ((n == 3 | n==16) &amp;&amp; s[1] == 4)
              {
                  printf(&quot;VISA\n&quot;);
              }
              else
              {
                  printf(&quot;INVALID\n&quot;);
              }
          }
      }
     // while ();
  }
  </code></pre>