title: C Pointer: char to binary value
body: <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int * bin(char a);
  
  int main(void){
          char a='a';
          int k=0;
          int *binary;
  
          binary=bin(a);
          for(k=0; k&lt;8; k++){
                  printf("%d", *binary++); 
                  printf("\n");      
          }
  
          return 0;
  }
  int *bin(char a){
  
          int i=0;
          int *arr;
          int output[8];
          char c=a;
          for (i = 0; i &lt;8 ; ++i) {
                   output[8-i-1] = (a &gt;&gt; i) &amp; 1;
  
          }
          arr=&amp;output[0];
  //              for (i = 0; i &lt;8 ; ++i) {
  //              printf("%d", output[i]);
  //      }
  //      printf("\n");
  
          return arr;
  }
  </code></pre>
  
  <p>The ouptut should be the binary value of the char 'a'which is:
  0
  1
  1
  0
  0
  0
  0
  1</p>
  
  <p>but i got this instead:
  0
  -1216804320
  -1218095335
  -1216804320
  10
  -1076423592
  -1218208721
  -1216804320</p>
  
  <p>Is this a pointer problem?
  How do i fix it so it would print the right answer? thx!!</p>