title: Confusion on printing strings as integers in C
body: <p>I would like to know how the string is represented in integer, so I wrote the following program.</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]){
    char name[4] = {"@"};  
    printf("integer name %d\n", *(int*)name);  
    return 0;
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>integer name 64
  </code></pre>
  
  <p>This is understandable because <code>@</code> is <code>64</code> in integer, i.e., <code>0x40</code> in hex.</p>
  
  <p>Now I change the program into:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(int argc, char *argv[]){
    char name[4] = {"@@"};  
    printf("integer name %d\n", *(int*)name);  
    return 0;
  }
  </code></pre>
  
  <p>The output is:</p>
  
  <pre><code>integer name 16448
  </code></pre>
  
  <p>I dont understand this. Since <code>@@</code> is <code>0x4040</code> in hex. So it should be <code>2^12+2^6 = 4160</code><br>
  If I count the <code>'\0'</code> at the end of the string, then it should be <code>2^16+2^10 = 66560</code></p>
  
  <p>Could someone explain where <code>16448</code> comes from?</p>