title: ASCII strings and endianness
body: <p>An intern who works with me showed me an exam he had taken in computer science about endianness issues.  There was a question that showed an ASCII string "My-Pizza", and the student had to show how that string would be represented in memory on a little endian computer.  Of course, this sounds like a trick question because ASCII strings are not affected by endian issues.</p>
  
  <p>But shockingly, the intern claims his professor insists that the string would be represented as:</p>
  
  <pre><code>P-yM azzi
  </code></pre>
  
  <p>I know this can't be right.  There is no way an ASCII string would be represented like that on any machine.  But apparently, the professor is insisting on this.  So, I wrote up a small C program and told the intern to give it to his professor.</p>
  
  <pre><code>#include &lt;string.h&gt;
  #include &lt;stdio.h&gt;
  
  int main()
  {
      const char* s = "My-Pizza";
      size_t length = strlen(s);
      for (const char* it = s; it &lt; s + length; ++it) {
          printf("%p : %c\n", it, *it);
      }
  }
  </code></pre>
  
  <p>This clearly demonstrates that the string is stored as "My-Pizza" in memory.  A day later, the intern gets back to me and tells me the professor is now claiming that C is automagically converting the addresses to display the string in proper order.</p>
  
  <p>I told him his professor is insane, and this is clearly wrong.  But just to check my own sanity here, I decided to post this on stackoverflow so I could get others to confirm what I'm saying.  </p>
  
  <p>So, I ask : who is right here?</p>