title: C program to check little vs. big endian
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/2100331/c-macro-definition-to-determine-big-endian-or-little-endian-machine">C Macro definition to determine big endian or little endian machine?</a>  </p>
  </blockquote>
  
  
  
  <pre><code>int main()
  {
    int x = 1;
  
    char *y = (char*)&amp;x;
  
    printf("%c\n",*y+48);
  }
  </code></pre>
  
  <p>If it's little endian it will print 1.  If it's big endian it will print 0.  Is that correct?  Or will setting a char* to int x always point to the least significant bit, regardless of endianness?</p>