title: How come my output is segmentation failure?
body: <p>Im trying to make a cipher in C and am looping through 2 arrays to compare the sentence characters to alphabet ACSII values and then change those letters into the encrypted alphabet values. Here's what I've got so far:</p>
  
  <pre><code>#include &lt;cs50.h&gt;
  #include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(void)
  {
      string test = "JTREKYAVOGDXPSNCUIZLFBMWHQ";
      string sentence = "DEEEATSXYLAPHONEELEPHANTTY";
      int alphabet[26];
  
      for (int i = 0; i &lt; 26; i++)
      {
          alphabet[i] = i + 65;
      }
  
      for (int i = 0; i &lt; 26; i++)
      {
          for (int j = 0; j &lt; 26; j++)
          {
              if (sentence[i] == alphabet[j])
              {
                  sentence[i] = test[j];
              }
          }
      }
  
      printf("%s", sentence);
  
  }
  </code></pre>
  
  <p>So the output is "segmentation failure". I feel like I've looped through it properly, but then this wouldn't be the first time I've felt confident but looked stupid. </p>