title: ROT13 Implementation using Char Arrays
body: <p>I'm a newbie programmer who has been working on a ROT13 implementation as part of a tutorial and came across the following code. It outputs the correct characters however I'm not quite sure how it works and there is no explanation attached.</p>
  
  <pre><code>char rot13[] = { 'N','O','P','Q','R','S','T','U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M' };
  std::string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
  for (int i = 0; i &lt; alphabet.length(); i++) {
      std::cout &lt;&lt; rot13[alphabet[i] - 'A'];
  }
  </code></pre>
  
  <p>Specifically, I dont quite understand how minusing the 'A' from a character within the string alphabet provides us with our ROT13 number. I initially thought that 'A' corresponded to an index within rot13[] and minusing that would provide us with a new index, however wouldn't that indicate that any numbers beneath A's index (Z,Y,X...) would become negative indexes as a result and throw errors. </p>
  
  <p>Is anyone able to explain the logic behind this code to me?</p>